Axil_Accountants/docker-compose.prod.yml
Vadym Samoilenko 96ab1c5da6 fix: run DB migrations via migrator service, not standalone app
In Next.js standalone output (output: 'standalone') the src/migrations/
directory is not present on the filesystem, so payload.db.migrate()
could not discover migration files → home_page table was never created
→ getHomePage() threw a DB error → Server Components render failed.

Fix:
- Add `migrator` service to docker-compose.prod.yml (builds from the
  `migrator` Dockerfile stage which has the full src/ tree)
- migrator runs `pnpm payload migrate` before app starts
- app depends_on migrator: service_completed_successfully
- Remove payload.db.migrate() from instrumentation.ts (migrator handles it)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-23 21:31:52 +00:00

65 lines
1.5 KiB
YAML

services:
# Run pending Payload migrations before the app starts.
# Uses the `migrator` image stage (has full src/) so TS files are discoverable.
migrator:
build:
context: .
target: migrator
restart: "no"
networks:
- internal
env_file:
- .env.production
depends_on:
db:
condition: service_healthy
app:
build:
context: .
target: runner
restart: always
networks:
- traefik-public
- internal
labels:
- "traefik.enable=true"
- "traefik.http.routers.axil.entrypoints=websecure"
- "traefik.http.routers.axil.rule=Host(`axil.ai-impress.com`)"
- "traefik.http.routers.axil.tls.certresolver=cloudflare"
- "traefik.http.routers.axil.middlewares=security-headers@file"
- "traefik.http.services.axil.loadbalancer.server.port=3000"
- "traefik.docker.network=traefik-public"
env_file:
- .env.production
depends_on:
db:
condition: service_healthy
migrator:
condition: service_completed_successfully
db:
image: postgres:17-alpine
restart: always
networks:
- internal
environment:
POSTGRES_USER: ${DB_USER:-axil}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_NAME:-axil}
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U ${DB_USER:-axil}']
interval: 5s
timeout: 5s
retries: 10
networks:
traefik-public:
external: true
internal:
driver: bridge
volumes:
pgdata: