#!/bin/sh set -e # ============================================================================= # Docker Entrypoint Script # ============================================================================= # Handles runtime setup before starting the application: # - Decodes SF_PRIVATE_KEY_BASE64 to file if provided # - Runs Prisma migrations if DATABASE_URL is set # ============================================================================= echo "🚀 Starting Customer Portal Backend..." # Handle Salesforce private key from base64 environment variable if [ -n "$SF_PRIVATE_KEY_BASE64" ]; then echo "📝 Decoding Salesforce private key..." mkdir -p /app/secrets echo "$SF_PRIVATE_KEY_BASE64" | base64 -d > /app/secrets/sf-private.key chmod 600 /app/secrets/sf-private.key export SF_PRIVATE_KEY_PATH=/app/secrets/sf-private.key echo "✅ Salesforce private key configured" fi # Run database migrations if enabled if [ "$RUN_MIGRATIONS" = "true" ] && [ -n "$DATABASE_URL" ]; then echo "🗄️ Running database migrations..." npx prisma@6.14.0 migrate deploy --schema=/app/apps/bff/prisma/schema.prisma echo "✅ Migrations complete" fi echo "🌐 Starting server on port ${PORT:-4000}..." # Execute the main command (node dist/main.js) exec "$@"