Starts nginx inside the bash script

This commit is contained in:
Aaron Louie 2020-05-26 09:02:37 -04:00
parent 7dec58f54c
commit 47ddd834c7
2 changed files with 11 additions and 7 deletions

View File

@ -26,12 +26,9 @@ RUN chmod +x ./entrypoint.sh
# The entrypoint.sh script will run after the container finishes starting.
# Substitutes environment variables in nginx configuration and index.html,
# then reloads nginx.
# then starts/reloads nginx.
ENTRYPOINT ["./entrypoint.sh", \
"/etc/nginx/html/index.html,/etc/nginx/conf.d/default.conf", \
"PRODUCTION,API_URL,IRB_URL,HOME_ROUTE,BASE_HREF,PORT0", \
"/etc/nginx/html", \
"true"]
### STAGE 3: Profit! ###
CMD ["nginx", "-g", "daemon off;"]

View File

@ -89,9 +89,16 @@ done
if [ $num_args -ge 4 ] && [ "$4" == "true" ]; then
# Check to see if nginx command is available
if hash nginx 2> /dev/null; then
echo "Reloading nginx..."
# Check to see if nginx is already running
if [ -e /var/run/nginx.pid ]; then
echo "nginx is currently running. Reloading nginx..."
exec nginx -s reload
echo "nginx reloaded."
else
echo "nginx is not yet running. Starting nginx..."
exec nginx -g 'daemon off;'
echo "nginx started."
fi
else
echo "nginx command not found on this system."
fi