Fix CI/CD database migration
Build and Deploy / build-and-push (push) Successful in 1m21s Details

This commit is contained in:
Ludo 2026-05-04 14:34:50 +02:00
parent 7d5c302422
commit edb0a52e41
3 changed files with 10 additions and 2 deletions

View File

@ -35,7 +35,8 @@ jobs:
docker compose -f docker-compose.prod.yml pull
docker run --rm --network infrastructure_infra-network \
-e DATABASE_URL=postgres://gitea:gitea@ludops-postgres:5432/${APP_NAME}_db \
-w /app \
${REGISTRY_IMAGE}:latest \
npx drizzle-kit push
node_modules/.bin/drizzle-kit push
docker compose -f docker-compose.prod.yml up -d --remove-orphans

View File

@ -22,6 +22,11 @@ WORKDIR /app
# Copy the standalone API (includes its own local node_modules)
COPY --from=build /prod/api .
# Copy drizzle config and schemas for migrations
COPY --from=build /app/apps/api/drizzle.config.ts ./drizzle.config.ts
COPY --from=build /app/apps/api/src/db/schemas.ts ./src/db/schemas.ts
COPY --from=build /app/apps/api/src/db/schemas/ ./src/db/schemas/
# Copy the web dist into the location the API expects
# Based on your code, it looks for ../web-dist or ./web-dist
COPY --from=build /app/apps/web/dist ./web-dist

View File

@ -4,6 +4,8 @@ export default {
out: './drizzle',
dialect: 'postgresql',
dbCredentials: {
url: 'postgres://postgres:postgres@localhost:5432/todo_db',
// In production, DATABASE_URL is set via docker-compose
// In local dev, it falls back to localhost
url: process.env.DATABASE_URL || 'postgres://postgres:postgres@localhost:5432/todo_db',
},
};