96 lines
3.4 KiB
YAML
96 lines
3.4 KiB
YAML
# ──────────────────────────────────────────────────────
|
|
# COOLIFY — docker-compose.coolify.yml
|
|
#
|
|
# Used by Coolify for ALL environments:
|
|
# main / develop → SPRING_PROFILES_ACTIVE=prod COMPOSE_PROFILES=with-db
|
|
# PR preview → SPRING_PROFILES_ACTIVE=dev COMPOSE_PROFILES= (H2, no DB)
|
|
#
|
|
# Coolify proxy=NONE → we manually expose through the forge's Traefik
|
|
# (network: proxy, certresolver: letsencrypt).
|
|
# ──────────────────────────────────────────────────────
|
|
|
|
services:
|
|
|
|
# ── Frontend (nginx + SPA) ────────────────────────
|
|
frontend:
|
|
build:
|
|
context: .
|
|
dockerfile: apps/frontend/Dockerfile
|
|
restart: unless-stopped
|
|
depends_on:
|
|
backend:
|
|
condition: service_healthy
|
|
networks:
|
|
- default
|
|
- proxy
|
|
labels:
|
|
- "traefik.enable=true"
|
|
- "traefik.http.routers.citygame.rule=Host(`citygame.pele.cam`)"
|
|
- "traefik.http.routers.citygame.entrypoints=https"
|
|
- "traefik.http.routers.citygame.tls=true"
|
|
- "traefik.http.routers.citygame.tls.certresolver=letsencrypt"
|
|
- "traefik.http.services.citygame.loadbalancer.server.port=80"
|
|
- "traefik.docker.network=proxy"
|
|
environment:
|
|
- SERVICE_FQDN_FRONTEND_80
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:80/healthz || exit 1"]
|
|
interval: 30s
|
|
timeout: 5s
|
|
start_period: 10s
|
|
retries: 3
|
|
|
|
# ── Backend (Spring Boot) ─────────────────────────
|
|
backend:
|
|
build:
|
|
context: .
|
|
dockerfile: apps/backend/Dockerfile
|
|
restart: unless-stopped
|
|
depends_on:
|
|
db:
|
|
# required: false → backend starts even when 'with-db' profile is
|
|
# inactive (PR previews). Spring 'dev' profile uses H2 in that case.
|
|
condition: service_healthy
|
|
required: false
|
|
environment:
|
|
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-dev}
|
|
DB_URL: ${DB_URL:-jdbc:postgresql://db:5432/citygame}
|
|
DB_USERNAME: ${DB_USERNAME:-citygame}
|
|
DB_PASSWORD: ${DB_PASSWORD:-citygame}
|
|
CORS_ALLOWED_ORIGINS: ${CORS_ALLOWED_ORIGINS:-http://localhost}
|
|
JAVA_TOOL_OPTIONS: "-XX:+UseContainerSupport -XX:MaxRAMPercentage=75.0"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "wget -qO- http://localhost:8080/actuator/health || exit 1"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
start_period: 30s
|
|
retries: 3
|
|
|
|
# ── Database (stable envs only) ───────────────────
|
|
# Activated via: COMPOSE_PROFILES=with-db
|
|
# PR previews leave COMPOSE_PROFILES empty → this service is skipped.
|
|
db:
|
|
image: postgres:16-alpine
|
|
restart: unless-stopped
|
|
profiles:
|
|
- with-db
|
|
environment:
|
|
POSTGRES_DB: ${DB_NAME:-citygame}
|
|
POSTGRES_USER: ${DB_USERNAME:-citygame}
|
|
POSTGRES_PASSWORD: ${DB_PASSWORD:-citygame}
|
|
volumes:
|
|
- pgdata:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME:-citygame} -d ${DB_NAME:-citygame}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 10s
|
|
|
|
volumes:
|
|
pgdata:
|
|
driver: local
|
|
|
|
networks:
|
|
proxy:
|
|
external: true
|