vn-docker/image-build.sh

43 lines
802 B
Bash
Raw Permalink Normal View History

#!/bin/bash
set -e
MY_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
2024-07-15 05:50:11 +00:00
source "$MY_DIR/image.conf"
# Prepare the environment
image=$1
version=$2
revision=$3
if [[ -z "$image" || -z "$version" ]]; then
echo "Usage: $0 <image> <version> [<revision>]"
exit 1
fi
tag="$version"
if [ ! -z "$revision" ]; then
tag="$tag-$revisionPrefix$revision"
fi
2024-07-15 05:50:11 +00:00
fullImage="$registry/$repository/$image"
latestImage="$fullImage:latest"
taggedImage="$fullImage:$tag"
echo "Image: $taggedImage"
read -p "Continue? (Default: no) [y|n]: " ANSWER
if [ "$ANSWER" != "y" ]; then
echo "Aborting push."
exit 3
fi
# Build and tag the image
docker build -t "$latestImage" "$image"
docker tag "$latestImage" "$taggedImage"
# Push the built image
docker push "$latestImage"
docker push "$taggedImage"