32 lines
813 B
Bash
32 lines
813 B
Bash
#!/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
|