docker-compose.prod.yml
2,022 bytes
| 1 | # Production compose — for the VPS (travel.rasmusj.com). |
|---|---|
| 2 | # Differences from docker-compose.yml (local): |
| 3 | # - No public ports anywhere. Caddy (on the external `web` network) is the only entrypoint. |
| 4 | # - Postgres lives only on the internal network — unreachable from the internet. |
| 5 | # - All secrets come from .env (never committed). See .env.example. |
| 6 | # |
| 7 | # Caddy reaches the app by container name: reverse_proxy csweb-travel:8080 |
| 8 | # Requires the shared external network to exist on the server: docker network create web |
| 9 | services: |
| 10 | db: |
| 11 | image: postgres:16 |
| 12 | restart: unless-stopped |
| 13 | environment: |
| 14 | POSTGRES_DB: splitapp |
| 15 | POSTGRES_USER: postgres |
| 16 | POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} |
| 17 | volumes: |
| 18 | - pgdata:/var/lib/postgresql/data |
| 19 | networks: |
| 20 | - internal |
| 21 | healthcheck: |
| 22 | test: ["CMD-SHELL", "pg_isready -U postgres -d splitapp"] |
| 23 | interval: 10s |
| 24 | timeout: 5s |
| 25 | retries: 5 |
| 26 | |
| 27 | app: |
| 28 | # CI builds & pushes this image (GitHub Actions → GHCR); the server only pulls it. |
| 29 | # `build` is kept as a fallback for manual `docker compose ... build` on the server. |
| 30 | image: ghcr.io/rasmusjy/cswebtravel:latest |
| 31 | build: . |
| 32 | container_name: csweb-travel |
| 33 | restart: unless-stopped |
| 34 | environment: |
| 35 | - ConnectionStrings__DefaultConnection=Host=db;Port=5432;Database=splitapp;Username=postgres;Password=${POSTGRES_PASSWORD} |
| 36 | - JWT__Key=${JWT_KEY} |
| 37 | - SEED_ADMIN_PASSWORD=${SEED_ADMIN_PASSWORD} |
| 38 | - ASPNETCORE_URLS=http://+:8080 |
| 39 | # Seeding is idempotent (guards on existing rows) — safe to leave on across restarts. |
| 40 | - DataInitialization__DropDatabase=false |
| 41 | - DataInitialization__MigrateDatabase=true |
| 42 | - DataInitialization__SeedIdentity=true |
| 43 | - DataInitialization__SeedData=true |
| 44 | depends_on: |
| 45 | db: |
| 46 | condition: service_healthy |
| 47 | networks: |
| 48 | - web # shared with Caddy — public entrypoint |
| 49 | - internal # private link to db |
| 50 | |
| 51 | networks: |
| 52 | web: |
| 53 | external: true |
| 54 | internal: |
| 55 | |
| 56 | volumes: |
| 57 | pgdata: |
| 58 | |