diff options
Diffstat (limited to 'bin/docker-dotenv')
| -rwxr-xr-x | bin/docker-dotenv | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/bin/docker-dotenv b/bin/docker-dotenv new file mode 100755 index 0000000..ca025c0 --- /dev/null +++ b/bin/docker-dotenv @@ -0,0 +1,33 @@ +#!/bin/sh + +# input: +# SOURCE_IMAGE: Image name for the source image +# TARGET_IMAGE: Name of image to build +# DOTENV: The name of the .env.* file that contains the default env vars to export. +# e.g. DOTENV=".env.12-3-stable" + +set -e + +cd "$(dirname "$0")/.." +DOCKERFILE=Dockerfile.env + +rm -f $DOCKERFILE +touch $DOCKERFILE +echo "FROM $SOURCE_IMAGE" > $DOCKERFILE + +echo "Reading... $DOTENV" +cat $DOTENV + +while IFS= read -r line; do + echo "ENV $line" >> $DOCKERFILE +done < $DOTENV + +echo "Pulling... $SOURCE_IMAGE" +docker pull $SOURCE_IMAGE + +echo "Building... $DOCKERFILE and tagging $TARGET_IMAGE" +cat $DOCKERFILE +docker build -t $TARGET_IMAGE -f $DOCKERFILE . + +echo "Verifying env..." +docker run --entrypoint='' $TARGET_IMAGE env |
