Files
AFC-Demo/deploy/docker-entrypoint.sh
T
2025-10-30 11:05:56 +01:00

45 lines
1.2 KiB
Bash

#!/bin/sh
set -e
SERVER_NAME="${SERVER_NAME:-$(hostname -f 2>/dev/null || hostname)}"
export SERVER_NAME
# Prepare BASIC_AUTH_DIRECTIVES
if [ "$ENABLE_BASIC_AUTH" = "true" ]; then
echo "[entrypoint] Enabling basic authentication..."
if [ -f /etc/nginx/htpasswd ]; then
BASIC_AUTH_DIRECTIVES=$(cat <<EOF
auth_basic "Restricted Content";
auth_basic_user_file /etc/nginx/htpasswd;
EOF
)
else
echo "[entrypoint] ERROR: htpasswd file not found at /etc/nginx/htpasswd" >&2
exit 1
fi
else
echo "[entrypoint] Basic authentication is disabled."
BASIC_AUTH_DIRECTIVES=""
fi
# Render the NGINX configuration
if [ -f /etc/nginx/templates/default.conf.template ]; then
envsubst '$SERVER_NAME,$BASIC_AUTH_DIRECTIVES' < /etc/nginx/templates/default.conf.template > /etc/nginx/http.d/default.conf
else
echo "[entrypoint] ERROR: missing /etc/nginx/templates/default.conf.template" >&2
exit 1
fi
# Test nginx configuration
if ! nginx -t; then
echo "[entrypoint] nginx config test failed" >&2
cat /var/log/nginx/error.log || true
exit 1
fi
# Clear Laravel caches
php artisan config:clear
php artisan cache:clear
# Start supervisord
exec /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf