CityGame/docker-compose.coolify.yml
Camille 7b2bdefee3
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was canceled
fix: frontend health check use 127.0.0.1 to avoid IPv6 resolution
2026-05-31 00:17:35 +02:00

83 lines
3.1 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 reads SERVICE_FQDN_FRONTEND_80 and auto-injects Traefik labels.
# Set the FQDN for each app in the Coolify UI — no manual labels needed.
# ──────────────────────────────────────────────────────
services:
# ── Frontend (nginx + SPA) ────────────────────────
frontend:
build:
context: .
dockerfile: apps/frontend/Dockerfile
restart: unless-stopped
depends_on:
backend:
condition: service_healthy
environment:
# Coolify replaces this value with the configured FQDN and injects
# the corresponding Traefik routing labels automatically.
- 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