2024-07-09 09:30:13 +00:00
|
|
|
#!/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"
|
2024-07-09 09:30:13 +00:00
|
|
|
|
|
|
|
# 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"
|
2024-07-09 09:30:13 +00:00
|
|
|
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"
|