#!/bin/bash -ex
# you must be logged into docker for the push to succeed.

versuffix=${1:+_$1} # tag name must be lower case
tag=$(date -u +%Y%m%dT%H%M%SZ)
TMPDIR=$(mktemp -d)

cp Dockerfile${versuffix} $TMPDIR

docker buildx build \
             --pull --file Dockerfile${versuffix} \
             --tag tsteven4/gpsbabel_build_environment${versuffix}:latest \
             --tag tsteven4/gpsbabel_build_environment${versuffix}:$tag \
             --progress=plain \
             $TMPDIR
/bin/rm -fr $TMPDIR
docker push tsteven4/gpsbabel_build_environment${versuffix}:$tag
docker push tsteven4/gpsbabel_build_environment${versuffix}:latest
docker image ls
