feat: Enhance deployment scripts with environment variable validation and loading

This commit is contained in:
2025-09-12 09:21:53 +02:00
parent 95ef139843
commit c1d49689da
3 changed files with 50 additions and 0 deletions

View File

@@ -10,6 +10,26 @@ GIT_REPO_URL=${1:-""}
GIT_BRANCH=${2:-"ui-fix"}
GIT_COMMIT=${3:-""}
# Check if .env.production exists and source it
if [ -f .env.production ]; then
echo "Loading production environment variables..."
export $(grep -v '^#' .env.production | xargs)
else
echo "Warning: .env.production not found. Make sure environment variables are set!"
fi
# Validate critical environment variables
# if [ -z "$NEXTAUTH_SECRET" ] || [ "$NEXTAUTH_SECRET" = "YOUR_SUPER_SECURE_SECRET_KEY_HERE_AT_LEAST_32_CHARACTERS_LONG" ]; then
# echo "ERROR: NEXTAUTH_SECRET must be set to a secure random string!"
# echo "Generate one with: openssl rand -base64 32"
# exit 1
# fi
if [ -z "$NEXTAUTH_URL" ]; then
echo "ERROR: NEXTAUTH_URL must be set to your production URL!"
exit 1
fi
if [ -z "$GIT_REPO_URL" ]; then
echo "Building from local files..."
docker-compose -f docker-compose.prod.yml build