nginx-routes/docker-entrypoint.sh

32 lines
813 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/usr/bin/env bash
set -Eeo pipefail
if [ -f "/invoke_initial_script.sh" ]; then
chmod +x /invoke_initial_script.sh
source /invoke_initial_script.sh
fi
# Проверяем наличие файла /etc/nginx/nginx.conf
if [ ! -f "/etc/nginx/nginx.conf" ]; then
# Заполняем файл /etc/nginx/nginx.conf с использованием переменных окружения
cat > /etc/nginx/nginx.conf <<EOF
events {}
stream {
server {
listen $NGINX_PROXY_SOURCE_PORT;
proxy_pass $NGINX_PROXY_TARGET_ADDRESS;
}
}
EOF
echo "Created default nginx conf forwarding from port '$NGINX_PROXY_SOURCE_PORT' to address '$NGINX_PROXY_TARGET_ADDRESS'"
else
echo "Skip default "
fi
if [[ "$1" = 'app' ]]; then
exec nginx -g 'daemon off;'
else
exec "$@"
fi