diff --git a/Dockerfile b/Dockerfile index 85f88fd..645a8ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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;"] diff --git a/docker/substitute-env-variables.sh b/docker/substitute-env-variables.sh index 36e49a3..909b083 100755 --- a/docker/substitute-env-variables.sh +++ b/docker/substitute-env-variables.sh @@ -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..." - exec nginx -s reload - echo "nginx reloaded." + # 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