Assist_Design/apps/bff/scripts/docker-entrypoint.sh
barsa 68561fdf1d Update pnpm-lock.yaml, Dockerfile, and error handling in BFF
- Enabled workspace package injection in pnpm-lock.yaml for improved dependency management.
- Removed outdated SHA256 files for backend and frontend tarballs.
- Refactored Dockerfile for BFF to streamline the build process and optimize production image size.
- Updated Prisma client configuration to specify binary targets for Alpine compatibility.
- Enhanced error handling in WhmcsLinkWorkflowService to use BadRequestException for clearer client feedback.
- Adjusted entrypoint script to ensure proper database migration execution.
2025-12-02 10:05:11 +09:00

36 lines
1.3 KiB
Bash
Executable File

#!/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 "$@"