Files
web_server/nginx/entrypoint.sh
Adam French 61366e4039
Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled
Add fail2ban to stop these malicious ips ;-;
2026-03-09 14:18:01 +00:00

30 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
set -e
# Check if dev mode, certificate exists, or setup mode
if [ "$DEV_MODE" = "true" ]; then
echo "Dev mode. Using HTTP-only nginx config."
envsubst '${DOMAIN} ${BACKEND_HOST} ${BACKEND_PORT} ${BACKEND_ENDPOINT} ${ICECAST_HOST} ${ICECAST_PORT} ${GITEA_HOST} ${GITEA_PORT}' \
< /etc/nginx/nginx_dev.conf.template \
> /etc/nginx/nginx.conf
elif [ -f "/etc/letsencrypt/live/$DOMAIN/fullchain.pem" ] && [ -f "/etc/letsencrypt/live/$DOMAIN/privkey.pem" ]; then
echo "Certificates found. Using production nginx config."
envsubst '${DOMAIN} ${BACKEND_HOST} ${BACKEND_PORT} ${BACKEND_ENDPOINT} ${ICECAST_HOST} ${ICECAST_PORT} ${GITEA_HOST} ${GITEA_PORT}' \
< /etc/nginx/nginx.conf.template \
> /etc/nginx/nginx.conf
else
echo "Certificates NOT found. Using setup nginx config."
envsubst '${DOMAIN}' < /etc/nginx/nginx_setup.conf.template > /etc/nginx/nginx.conf
fi
# Ensure log directory and files exist on the shared volume
mkdir -p /var/log/nginx
touch /var/log/nginx/access.log /var/log/nginx/error.log
# Ensure uploads directory and files are readable by nginx worker processes
chmod 755 /uploads 2>/dev/null || true
chmod -R a+rX /uploads 2>/dev/null || true
# Start nginx
nginx -g 'daemon off;'