Last active
July 9, 2021 17:46
-
-
Save misebox/c7b710e74c5a30809ff79724a3f8e816 to your computer and use it in GitHub Desktop.
Script for using environment variables in /etc/nginx/**/*.conf.template
This file contains 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 | |
# Create /etc/nginx/**/*.conf from replacing the strings like | |
# ${NGINX_xxxxx} contained in /etc/nginx/**/*.conf.template | |
# with the value of each environment variable. | |
envs="$(env | egrep '^NGINX_' | sed -r 's/^(.+)=.*/\$\$\1/g')" | |
for template in `find /etc/nginx -name '*.conf.template'` | |
do | |
conf=`basename -s .template $template` | |
envsubst "$envs" \ | |
< "$template" \ | |
> "$conf" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use with docker-compose: