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:
18
apps/api/docker-entrypoint.sh
Executable file
18
apps/api/docker-entrypoint.sh
Executable 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 "$@"
|
||||
Reference in New Issue
Block a user