Skip to content

Commit

Permalink
No, just gonna to it this way
Browse files Browse the repository at this point in the history
  • Loading branch information
adamrdrew committed Nov 7, 2023
1 parent 4f94b1d commit 625d549
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions build_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,6 @@ set -exv

IMAGE="quay.io/cloudservices/frontend-operator"
IMAGE_TAG=$(git rev-parse --short=7 HEAD)
# Generate a unique builder name using Jenkins environment variables
BUILDER_NAME="builder-${JOB_NAME}-${BUILD_ID}"

# Function to remove Docker builder
cleanup() {
echo "Cleaning up Docker builder..."
# Check if the specified builder exists and remove it if it does
docker buildx inspect "$BUILDER_NAME" &>/dev/null && docker buildx rm "$BUILDER_NAME"
}

# Create a trap for different signals
# It will call the cleanup function on EXIT, or if the script receives
# a SIGINT (Ctrl+C), or a SIGTERM (termination signal)
trap cleanup EXIT SIGINT SIGTERM

if [[ -z "$QUAY_USER" || -z "$QUAY_TOKEN" ]]; then
echo "QUAY_USER and QUAY_TOKEN must be set"
Expand Down Expand Up @@ -54,15 +40,14 @@ fi
#### End


docker buildx use multiarchbuilder


# Create a new buildx builder with the unique name
docker buildx create --name "${BUILDER_NAME}" --use --driver docker-container --driver-opt image=quay.io/domino/buildkit:v0.12.3
docker --config="$DOCKER_CONF" buildx build --platform linux/amd64 --build-arg BASE_IMAGE="$BASE_IMG" --build-arg GOARCH="amd64" -t "${IMAGE}:${IMAGE_TAG}-amd64" --push .
docker --config="$DOCKER_CONF" buildx build --platform linux/arm64 --build-arg BASE_IMAGE="$BASE_IMG" --build-arg GOARCH="arm64" -t "${IMAGE}:${IMAGE_TAG}-arm64" --push .

# Initialize the builder
docker buildx inspect "${BUILDER_NAME}" --bootstrap
docker --config="$DOCKER_CONF" manifest create "${IMAGE}:${IMAGE_TAG}" \
"${IMAGE}:${IMAGE_TAG}-amd64" \
"${IMAGE}:${IMAGE_TAG}-arm64"

# Build and push the multi-architecture image
docker --config="$DOCKER_CONF" buildx build --builder "${BUILDER_NAME}" \
--platform linux/amd64,linux/arm64 \
--build-arg BASE_IMAGE="$BASE_IMG" \
-t "${IMAGE}:${IMAGE_TAG}" --push .
docker --config="$DOCKER_CONF" manifest push "${IMAGE}:${IMAGE_TAG}"

0 comments on commit 625d549

Please sign in to comment.