diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index f735a70..8d15950 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -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 diff --git a/Dockerfile b/Dockerfile index b464928..0145a46 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/apps/api/drizzle.config.ts b/apps/api/drizzle.config.ts index f6bf898..85cceb8 100644 --- a/apps/api/drizzle.config.ts +++ b/apps/api/drizzle.config.ts @@ -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', }, }; \ No newline at end of file