Created
July 19, 2016 19:03
-
-
Save aurelijusb/ce672b88fff5aa2340cc4f97d65511dd to your computer and use it in GitHub Desktop.
Example of my-nginx/run.sh. For presentation: Docker on AWS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| echo -e "`date +'%Y-%m-%d %T.%N%z'` Starting Nginx..." | |
| CONFIG_SRC=/custom/config/site.conf | |
| CONFIG_DEST=/etc/nginx/conf.d/site.conf | |
| CONFIG_LOGS=/custom/logs | |
| # Replacing needed environment variables in config (envsubst will break $uri) | |
| # Store final config in logs, for easier debugging | |
| # Start nginx without daemon,as docker keeps control over daemon | |
| # Update configuration with environment variables | |
| CONFIG_TMP="$CONFIG_DEST.tmp" | |
| cp ${CONFIG_SRC} ${CONFIG_TMP} | |
| for LINE in `env`; do | |
| IN=`echo $LINE | cut -d "=" -f 1` | |
| OUT=`echo $LINE | cut -d "=" -f 2` | |
| sed -e "s#\${$IN}#$OUT#g" < ${CONFIG_TMP} > ${CONFIG_DEST} | |
| cat ${CONFIG_DEST} > ${CONFIG_TMP} | |
| done | |
| rm ${CONFIG_TMP} | |
| cat ${CONFIG_DEST} > ${CONFIG_LOGS}/site.conf.bak | |
| # running nginx | |
| nginx -g 'daemon off;' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment