szabadpalya/compose.yaml

63 lines
2.2 KiB
YAML

# For development the database alone is enough: ./scripts/db.sh up
# Full / production run: docker compose up -d --build
#
# SESSION_SECRET must be set in the environment or in a .env file next to this
# one. It is not marked required here because compose resolves every variable in
# the file whatever service you name, and that would break `./scripts/db.sh up`.
# The server refuses to start without it and says so.
services:
db:
image: postgres:17-alpine
container_name: szabadpalya-db
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-szabadpalya}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-szabadpalya}
POSTGRES_DB: ${POSTGRES_DB:-szabadpalya}
ports:
- "5433:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-szabadpalya} -d ${POSTGRES_DB:-szabadpalya}"]
interval: 5s
timeout: 3s
retries: 10
# Runs once, migrates, exits. The app starts only after it succeeds.
migrate:
build:
context: .
target: migrator
environment:
DATABASE_URL: postgresql://${POSTGRES_USER:-szabadpalya}:${POSTGRES_PASSWORD:-szabadpalya}@db:5432/${POSTGRES_DB:-szabadpalya}
SESSION_SECRET: ${SESSION_SECRET:-}
depends_on:
db:
condition: service_healthy
restart: "no"
app:
build:
context: .
target: runner
environment:
DATABASE_URL: postgresql://${POSTGRES_USER:-szabadpalya}:${POSTGRES_PASSWORD:-szabadpalya}@db:5432/${POSTGRES_DB:-szabadpalya}
SESSION_SECRET: ${SESSION_SECRET:-}
BASE_URL: ${BASE_URL:-http://localhost:3000}
ADMIN_EMAILS: ${ADMIN_EMAILS:-}
ports:
- "3000:3000"
depends_on:
migrate:
condition: service_completed_successfully
restart: unless-stopped
# Declared, and named explicitly. Without the name compose would derive one from
# the project directory (szabadpalya_pgdata) while scripts/db.sh's no-compose
# path uses szabadpalya-pgdata — two databases, one of them silently empty,
# depending on whether the compose plugin happens to be installed.
volumes:
pgdata:
name: szabadpalya_pgdata