Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

A lightweight Quarkus‑based microservice that automates configuration, experiment creation, profile validation, and health orchestration for Kruize Autotune, simplifying the experience for SREs and Platform Engineers.


## Prerequisites

- **Java 25** - Required to build the Docker image and run the application

## Deployment

### Deploy to Kind (local development)
Expand Down
90 changes: 90 additions & 0 deletions build_and_push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/bash
set -euo pipefail

# Usage function
usage() {
local exit_code="${1:-1}"
echo "Usage: $0 [OPTIONS]"
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 " -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)"
echo " -h Show this help message"
echo ""
echo "Examples:"
echo " $0 -i quay.io/myuser/kruize-optimizer:1.0.0 -b true -p true"
echo " $0 -t 0.1_mvp -p false"
echo " $0 -b true -p true -l linux/amd64"
echo ""
echo "Note: Use either -i for full image name OR -t for tag with default registry/repo"
exit "${exit_code}"
}

# Validate boolean values
validate_boolean() {
local value="$1"
local flag="$2"
if [[ ! "$value" =~ ^(true|false)$ ]]; then
echo "Error: $flag must be 'true' or 'false', got: '$value'" >&2
usage 1
fi
}

# Default values
IMAGE_TAG="0.1"
QUARKUS_BUILD="true"
QUARKUS_PUSH="true"
QUARKUS_PLATFORMS="linux/amd64,linux/arm64"
IMAGE_NAME=""

# Parse command line arguments
while getopts "i:t:b:p:l:h" opt; do
case ${opt} in
i )
IMAGE_NAME="$OPTARG"
;;
t )
IMAGE_TAG="$OPTARG"
;;
b )
QUARKUS_BUILD="$OPTARG"
;;
p )
QUARKUS_PUSH="$OPTARG"
;;
l )
QUARKUS_PLATFORMS="$OPTARG"
;;
h )
usage 0
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage 1
;;
esac
done

# Validate boolean flags
validate_boolean "$QUARKUS_BUILD" "-b"
validate_boolean "$QUARKUS_PUSH" "-p"

# If IMAGE_NAME is not provided via -i, use default registry/repository with tag
if [ -z "$IMAGE_NAME" ]; then
IMAGE_NAME="quay.io/kruize/optimizer:${IMAGE_TAG}"
fi

echo "Building and pushing image: ${IMAGE_NAME}..."
echo "Build: ${QUARKUS_BUILD}"
echo "Push: ${QUARKUS_PUSH}"
echo "Platforms: ${QUARKUS_PLATFORMS}"

# Build container image using Quarkus Jib extension
./mvnw clean package \
-Dquarkus.container-image.build="${QUARKUS_BUILD}" \
-Dquarkus.container-image.image="${IMAGE_NAME}" \
-Dquarkus.container-image.push="${QUARKUS_PUSH}" \
-Dquarkus.jib.platforms="${QUARKUS_PLATFORMS}"