fix: run migrations from build stage (has pnpm)

Runner stage is minimal — no pnpm. Add migrator service using
build target which has full node_modules + pnpm.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vadym Samoilenko 2026-02-23 13:59:57 +00:00
parent 2c115bab99
commit ecc2c94e5f
2 changed files with 15 additions and 2 deletions

View file

@ -255,8 +255,8 @@ start_containers() {
run_migrations() {
header "Phase 5 — Database migrations"
log "Running Payload CMS migrations..."
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" exec -T app pnpm payload migrate
log "Running Payload CMS migrations (via build stage — has pnpm + full node_modules)..."
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" --profile migrate run --rm migrator
log "Migrations complete."
}

View file

@ -12,6 +12,19 @@ services:
db:
condition: service_healthy
migrator:
build:
context: .
target: build
command: pnpm payload migrate
env_file:
- .env.production
depends_on:
db:
condition: service_healthy
profiles:
- migrate
db:
image: postgres:17-alpine
restart: always