diff --git a/build-helper.sh b/build-helper.sh new file mode 100755 index 0000000..c9c89eb --- /dev/null +++ b/build-helper.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +set -e + +old_pwd=$(pwd) +cd $2 + +echo "Build will be tagged with $1" +echo "Build directory is $(pwd)" + +OLD_IMG=$(docker image ls -q "$1") +docker buildx build . -t "$1" + +echo "Build complete, starting upload..." +docker push "$1" + +if [ -n "$OLD_IMG" ]; then + if [ "$OLD_IMG" != "$(docker image ls -q "$1")" ]; then + echo "New build uploaded, removing old image, id: $OLD_IMG" + docker image rmi -f "$OLD_IMG" || true + echo "Exit status: $?" + fi +fi + +cd $old_pwd diff --git a/build.sh b/build.sh index f6370d7..5348b41 100755 --- a/build.sh +++ b/build.sh @@ -3,29 +3,24 @@ echo " Building base container " -cd base -docker buildx build . -t git.janishutz.com/registry/dev-container-base +./build-helper.sh git.janishutz.com/registry/dev-container-base base echo " Building npm container " -cd ../npm -docker buildx build . -t git.janishutz.com/registry/dev-container-npm +./build-helper.sh git.janishutz.com/registry/dev-container-npm npm echo " Building Vue container " -cd ../vue -docker buildx build . -t git.janishutz.com/registry/dev-container-vue +./build-helper.sh git.janishutz.com/registry/dev-container-vue vue # # echo " # Building Python container # " -# cd ../python -# docker buildx build . -t git.janishutz.com/registry/dev-container-python +# ./build-helper.sh git.janishutz.com/registry/dev-container-python python # # echo " # Building php container # " -# cd ../php -# docker buildx build . -t git.janishutz.com/registry/dev-container-php +# ./build-helper.sh git.janishutz.com/registry/dev-container-php php