feat(devops): improve multi-stage production Dockerfile for NestJS API

- Use pnpm deploy --prod for pruned production node_modules (smaller image)
- Add docker-entrypoint.sh with optional Prisma migration support (RUN_MIGRATIONS)
- Copy generated Prisma client explicitly into production stage
- Add OCI image labels for container registry metadata
- Update .dockerignore: exclude apps/web, libs/ai-services, agent configs, Python artifacts
- Add build directive + RUN_MIGRATIONS env to docker-compose.prod.yml
- Maintain non-root user, dumb-init signal handling, and healthcheck

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Ho Ngoc Hai
2026-04-09 01:23:06 +07:00
parent e89cd0ce84
commit 60830d00d0
4 changed files with 79 additions and 7 deletions

18
apps/api/docker-entrypoint.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/sh
set -e
# =============================================================================
# GoodGo API — Docker Entrypoint
#
# Optionally runs Prisma migrations before starting the application.
# Set RUN_MIGRATIONS=true to apply pending migrations on startup.
# In Kubernetes, prefer running migrations as an init container instead.
# =============================================================================
if [ "${RUN_MIGRATIONS}" = "true" ]; then
echo "[entrypoint] Running Prisma migrations..."
npx prisma migrate deploy --schema ./prisma/schema.prisma
echo "[entrypoint] Migrations complete."
fi
exec "$@"