diff options
| author | mo khan <mo.khan@gmail.com> | 2019-08-22 11:38:50 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2019-08-22 11:38:50 -0600 |
| commit | ead82e380d385450df7e507d1cb9cca15804ee5a (patch) | |
| tree | 388e80c7025f9ca03c8626b1604ec6addb997c3d /bin | |
| parent | b94b08f7441372074a0b0286837eb25c2ff9ad11 (diff) | |
create script to inject environment variables into an existing image
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/docker-inject-env | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/bin/docker-inject-env b/bin/docker-inject-env new file mode 100755 index 0000000..e404cec --- /dev/null +++ b/bin/docker-inject-env @@ -0,0 +1,24 @@ +#!/bin/sh + +# input: +# SOURCE_IMAGE: Image name for the source image +# TARGET_IMAGE: Name of image to build +# DOTENV: The list of env variables delimited by a ; +# e.g. DOTENV="FEATURE_RUBY_REPORT 'false';LM_REPORT_VERSION 1;" + +set -e + +cd "$(dirname "$0")/.." +DOCKERFILE=Dockerfile.env + +rm -f $DOCKERFILE +touch $DOCKERFILE +echo "FROM $SOURCE_IMAGE" > $DOCKERFILE + +IFS=';' read -ra EACH_ENV <<< "$DOTENV" +for i in "${EACH_ENV[@]}"; do + echo "ENV $i" >> $DOCKERFILE +done + +docker pull $SOURCE_IMAGE +docker build -t $TARGET_IMAGE -f $DOCKERFILE . |
