Skip to content

Commit

Permalink
Thrashing
Browse files Browse the repository at this point in the history
  • Loading branch information
adamrdrew committed Nov 7, 2023
1 parent 58e7946 commit 6224bdb
Showing 1 changed file with 11 additions and 32 deletions.
43 changes: 11 additions & 32 deletions build_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,10 @@ DOCKER_CONF="$PWD/.docker"
mkdir -p "$DOCKER_CONF"


docker buildx use multiarchbuilder

# Function to remove Docker builder
cleanup() {
echo "Cleaning up Docker builder..."
# Check if the specified builder exists and remove it if it does
docker --config="$DOCKER_CONF" 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


# Create a new buildx builder with the unique name
docker --config="$DOCKER_CONF" buildx create --platform linux/amd64,linux/arm64 --name "$BUILDER_NAME" --use --driver docker-container --driver-opt image=quay.io/domino/buildkit:v0.12.3

# Initialize the builder
docker --config="$DOCKER_CONF" buildx inspect "$BUILDER_NAME" --bootstrap


docker --config="$DOCKER_CONF" buildx use "$BUILDER_NAME"

docker --config="$DOCKER_CONF" login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io
docker --config="$DOCKER_CONF" login -u="$RH_REGISTRY_USER" -p="$RH_REGISTRY_TOKEN" registry.redhat.io
docker login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io
docker login -u="$RH_REGISTRY_USER" -p="$RH_REGISTRY_TOKEN" registry.redhat.io

### Start base image build and push
BASE_TAG=`cat go.mod go.sum Dockerfile.base | sha256sum | head -c 8`
Expand All @@ -58,21 +37,21 @@ echo "received HTTP response: $RESPONSE"
VALID_TAGS_LENGTH=$(echo $RESPONSE | jq '[ .tags[] | select(.end_ts == null) ] | length')

if [[ "$VALID_TAGS_LENGTH" -eq 0 ]]; then
docker --config="$DOCKER_CONF" buildx build --platform linux/amd64 -f Dockerfile.base -t "${BASE_IMG}-amd64" --push .
docker --config="$DOCKER_CONF" buildx build --platform linux/arm64 -f Dockerfile.base -t "${BASE_IMG}-arm64" --push .
docker --config="$DOCKER_CONF" manifest create "${BASE_IMG}" \
docker buildx build --platform linux/amd64 -f Dockerfile.base -t "${BASE_IMG}-amd64" --push .
docker buildx build --platform linux/arm64 -f Dockerfile.base -t "${BASE_IMG}-arm64" --push .
docker manifest create "${BASE_IMG}" \
"${BASE_IMG}-amd64" \
"${BASE_IMG}-arm64"
docker --config="$DOCKER_CONF" push "$BASE_IMG"
docker push "$BASE_IMG"
fi
#### End


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 .
docker buildx build --platform linux/amd64 --build-arg BASE_IMAGE="$BASE_IMG" --build-arg GOARCH="amd64" -t "${IMAGE}:${IMAGE_TAG}-amd64" --push .
docker buildx build --platform linux/arm64 --build-arg BASE_IMAGE="$BASE_IMG" --build-arg GOARCH="arm64" -t "${IMAGE}:${IMAGE_TAG}-arm64" --push .

docker --config="$DOCKER_CONF" manifest create "${IMAGE}:${IMAGE_TAG}" \
docker manifest create "${IMAGE}:${IMAGE_TAG}" \
"${IMAGE}:${IMAGE_TAG}-amd64" \
"${IMAGE}:${IMAGE_TAG}-arm64"

docker --config="$DOCKER_CONF" manifest push "${IMAGE}:${IMAGE_TAG}"
docker manifest push "${IMAGE}:${IMAGE_TAG}"

0 comments on commit 6224bdb

Please sign in to comment.