Files
workflow-templates/docker/build/build-image.sh
2025-12-23 20:13:31 +01:00

24 lines
446 B
Bash
Executable File

#!/bin/sh
set -e
echo "=> Build will be tagged with $1 and 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
fi
fi