Created
April 12, 2017 09:11
-
-
Save zerda/df577cf788ba74aad60147394eae4bba to your computer and use it in GitHub Desktop.
Merge environment variables to Docker container files
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 | |
if [[ -n "$CONFIG_PATH" ]]; then | |
printf "Merging environment variables to '$CONFIG_PATH'.\n" | |
if [[ -n "$BASE_URL" ]]; then | |
tmp=$(mktemp) | |
jq '.baseUrl = $value' $CONFIG_PATH --arg value $BASE_URL > $tmp && mv $tmp $CONFIG_PATH | |
printf "baseUrl = '$BASE_URL'\n" | |
fi | |
chmod 644 $CONFIG_PATH | |
printf "Merge operation has been done.\n" | |
fi | |
exec "$@" |
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
FROM nginx:alpine | |
EXPOSE 80 | |
RUN apk add --update --no-cache jq | |
ADD ./docker-entrypoint.sh / | |
ADD ./config.json ./index.html /usr/share/nginx/html/ | |
ENV CONFIG_PATH=/usr/share/nginx/html/config.json | |
ENTRYPOINT ["/docker-entrypoint.sh"] | |
CMD ["nginx", "-g", "daemon off;"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment