executable + rem whitespace

This commit is contained in:
2026-04-11 17:12:25 -05:00
parent 94206afd49
commit 666c7724c5

112
innungsapp/apps/admin/docker-entrypoint.sh Normal file → Executable file
View File

@@ -1,56 +1,56 @@
#!/bin/sh #!/bin/sh
set -e set -e
# Keep DATABASE_URL consistent for every Prisma command # Keep DATABASE_URL consistent for every Prisma command
export DATABASE_URL="${DATABASE_URL:-postgresql://innungsapp:innungsapp@postgres:5432/innungsapp?schema=public}" export DATABASE_URL="${DATABASE_URL:-postgresql://innungsapp:innungsapp@postgres:5432/innungsapp?schema=public}"
MIGRATIONS_DIR="./packages/shared/prisma/migrations" MIGRATIONS_DIR="./packages/shared/prisma/migrations"
# Debug: Check environment variables # Debug: Check environment variables
echo "========================================" echo "========================================"
echo "Environment Variables Check:" echo "Environment Variables Check:"
echo "========================================" echo "========================================"
echo "DATABASE_URL: $DATABASE_URL" echo "DATABASE_URL: $DATABASE_URL"
echo "BETTER_AUTH_URL: ${BETTER_AUTH_URL:-[not set]}" echo "BETTER_AUTH_URL: ${BETTER_AUTH_URL:-[not set]}"
echo "BETTER_AUTH_BASE_URL: ${BETTER_AUTH_BASE_URL:-[not set]}" echo "BETTER_AUTH_BASE_URL: ${BETTER_AUTH_BASE_URL:-[not set]}"
if [ -n "$BETTER_AUTH_SECRET" ]; then if [ -n "$BETTER_AUTH_SECRET" ]; then
echo "BETTER_AUTH_SECRET: [set]" echo "BETTER_AUTH_SECRET: [set]"
else else
echo "BETTER_AUTH_SECRET: [not set]" echo "BETTER_AUTH_SECRET: [not set]"
fi fi
echo "NEXT_PUBLIC_APP_URL: ${NEXT_PUBLIC_APP_URL:-[not set]}" echo "NEXT_PUBLIC_APP_URL: ${NEXT_PUBLIC_APP_URL:-[not set]}"
echo "NODE_ENV: ${NODE_ENV:-[not set]}" echo "NODE_ENV: ${NODE_ENV:-[not set]}"
echo "========================================" echo "========================================"
echo "" echo ""
run_with_retries() { run_with_retries() {
attempt=1 attempt=1
max_attempts=20 max_attempts=20
while [ "$attempt" -le "$max_attempts" ]; do while [ "$attempt" -le "$max_attempts" ]; do
if "$@"; then if "$@"; then
return 0 return 0
fi fi
if [ "$attempt" -eq "$max_attempts" ]; then if [ "$attempt" -eq "$max_attempts" ]; then
echo "Command failed after ${max_attempts} attempts." echo "Command failed after ${max_attempts} attempts."
return 1 return 1
fi fi
echo "Database not ready yet. Retry ${attempt}/${max_attempts} in 3s..." echo "Database not ready yet. Retry ${attempt}/${max_attempts} in 3s..."
attempt=$((attempt + 1)) attempt=$((attempt + 1))
sleep 3 sleep 3
done done
} }
# Prefer migration-based deploys. Fall back to db push when no migrations exist yet. # Prefer migration-based deploys. Fall back to db push when no migrations exist yet.
set -- "$MIGRATIONS_DIR"/*/migration.sql set -- "$MIGRATIONS_DIR"/*/migration.sql
if [ -f "$1" ]; then if [ -f "$1" ]; then
echo "Applying Prisma migrations..." echo "Applying Prisma migrations..."
run_with_retries npx prisma migrate deploy --schema=./packages/shared/prisma/schema.prisma run_with_retries npx prisma migrate deploy --schema=./packages/shared/prisma/schema.prisma
else else
echo "No Prisma migrations found. Syncing schema with db push..." echo "No Prisma migrations found. Syncing schema with db push..."
run_with_retries npx prisma db push --skip-generate --schema=./packages/shared/prisma/schema.prisma run_with_retries npx prisma db push --skip-generate --schema=./packages/shared/prisma/schema.prisma
fi fi
echo "Starting Next.js server..." echo "Starting Next.js server..."
exec node apps/admin/server.js exec node apps/admin/server.js