2023-09-01 23:08:48 +02:00
|
|
|
|
#!/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
|
|
|
|
|
|
2023-09-08 10:31:39 +02:00
|
|
|
|
# Проверяем наличие файла /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
|
|
|
|
|
|
2023-09-01 23:08:48 +02:00
|
|
|
|
if [[ "$1" = 'app' ]]; then
|
|
|
|
|
exec nginx -g 'daemon off;'
|
|
|
|
|
else
|
|
|
|
|
exec "$@"
|
|
|
|
|
fi
|