Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions build_and_push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ usage() {
echo ""
echo "Options:"
echo " -i IMAGE_NAME Full image name (registry/repository:tag)"
echo " -t TAG Image tag (default: 0.1) - used only if -i is not provided"
echo " -t TAG Image tag (default: project version from pom.xml) - used only if -i is not provided"
echo " -b BUILD Build image true/false (default: true)"
echo " -p PUSH Push image true/false (default: true)"
echo " -l PLATFORMS Target platforms (default: linux/amd64,linux/arm64)"
Expand All @@ -34,7 +34,7 @@ validate_boolean() {
}

# Default values
IMAGE_TAG="0.1"
IMAGE_TAG=""
QUARKUS_BUILD="true"
QUARKUS_PUSH="true"
QUARKUS_PLATFORMS="linux/amd64,linux/arm64"
Expand Down Expand Up @@ -73,8 +73,16 @@ validate_boolean "$QUARKUS_BUILD" "-b"
validate_boolean "$QUARKUS_PUSH" "-p"

# If IMAGE_NAME is not provided via -i, use default registry/repository with tag
# (tag from -t, otherwise the project version from pom.xml)
if [ -z "$IMAGE_NAME" ]; then
IMAGE_NAME="quay.io/kruize/optimizer:${IMAGE_TAG}"
if [ -z "$IMAGE_TAG" ]; then
IMAGE_TAG="$(sed -n 's|^ <version>\(.*\)</version>.*|\1|p' pom.xml | head -n 1)"
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
if [ -z "$IMAGE_TAG" ]; then
echo "Error: could not read project version from pom.xml" >&2
exit 1
fi
fi
IMAGE_NAME="quay.io/kruize/kruize-optimizer:${IMAGE_TAG}"
fi

echo "Building and pushing image: ${IMAGE_NAME}..."
Expand Down
Loading