#!/bin/sh set -e # Known limitation: Multi-process under a single shell entrypoint means if one # process crashes, the container may remain partially alive. Production-grade # process supervision is a future concern, not a scaffold blocker. cleanup() { echo "Shutting down..." kill "$NGINX_PID" "$API_PID" "$WEB_PID" 2>/dev/null || true wait "$NGINX_PID" "$API_PID" "$WEB_PID" 2>/dev/null || true exit 0 } trap cleanup SIGTERM SIGINT # Start nginx nginx -g 'daemon off;' & NGINX_PID=$! # Run Prisma migrations cd /app/packages/api npx prisma migrate deploy # Start NestJS API PORT=3001 node dist/main.js & API_PID=$! # Start Next.js standalone cd /app/packages/web/standalone PORT=3000 HOSTNAME=0.0.0.0 node packages/web/server.js & WEB_PID=$! # Wait for any process to exit wait -n "$NGINX_PID" "$API_PID" "$WEB_PID"