From ecc2c94e5fe0fe194148d373b6ad246c9c2ee6d3 Mon Sep 17 00:00:00 2001 From: Vadym Samoilenko Date: Mon, 23 Feb 2026 13:59:57 +0000 Subject: [PATCH] fix: run migrations from build stage (has pnpm) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- deploy.sh | 4 ++-- docker-compose.prod.yml | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/deploy.sh b/deploy.sh index d0c947d..b3db676 100755 --- a/deploy.sh +++ b/deploy.sh @@ -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." } diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index fc0e82f..bacbbdc 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -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