nginx dockerfile

This commit is contained in:
2020-12-03 05:10:08 +01:00
parent 3a05927a60
commit 944e68acff
3 changed files with 62 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
#!/bin/bash
if [[ (! -z "${NGINX_DAEMON_USER}" ) && ( "${NGINX_DAEMON_USER}" != "root" ) ]]; then
useradd -r -s /bin/false $NGINX_DAEMON_USER
if [[ ! -z "${NGINX_DAEMON_USER_UID}" ]]; then
usermod -u $NGINX_DAEMON_USER_UID $NGINX_DAEMON_USER
fi
if [[ ! -z "${NGINX_DAEMON_USER_GID}" ]]; then
groupmod -g $NGINX_DAEMON_USER_GID $NGINX_DAEMON_USER
fi
fi
cp /etc/nginx/nginx.conf /etc/nginx/nginx_tmp.conf
sed -i "s/user .*;//" /etc/nginx/nginx_tmp.conf
echo "Chowning Data"
if [[ ! -z "${NGINX_DAEMON_USER}" ]]; then
chown -R $(id -u ${NGINX_DAEMON_USER}):$(id -g ${NGINX_DAEMON_USER}) /usr/share/nginx/html
chown -R $(id -u ${NGINX_DAEMON_USER}):$(id -g ${NGINX_DAEMON_USER}) /etc/nginx/nginx.conf
chown -R $(id -u ${NGINX_DAEMON_USER}):$(id -g ${NGINX_DAEMON_USER}) /var/log/nginx
sed -i "1s/^/user ${NGINX_DAEMON_USER};\n/" /etc/nginx/nginx_tmp.conf
else
chown -R $(id -u):$(id -g) /usr/share/nginx/html
chown -R $(id -u):$(id -g) /etc/nginx/nginx.conf
chown -R $(id -u):$(id -g) /var/log/nginx
sed -i "1s/^/user nginx;\n/" /etc/nginx/nginx_tmp.conf
fi
"$@" -c "/etc/nginx/nginx_tmp.conf" -g "daemon off;"