Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #56 from jtumber-ibm/platform-flag
Browse files Browse the repository at this point in the history
Use buildx for cross-platform builds
  • Loading branch information
k8s-ci-robot committed Jan 23, 2023
2 parents 1084303 + 2209355 commit b3f5d8f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 30 deletions.
10 changes: 7 additions & 3 deletions Dockerfile
Expand Up @@ -2,11 +2,15 @@
ARG GO_VERSION=1.18

# First stage: build the executable.
FROM golang:${GO_VERSION}-stretch AS builder
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-stretch AS builder

# Expose global args
ARG TARGETARCH
ARG TARGETOS

# What arch is it?
ARG GOARCH=amd64
ARG GOOS=linux
ARG GOARCH=$TARGETARCH
ARG GOOS=$TARGETOS

# Install the Certificate-Authority certificates for the app to be able to make
# calls to HTTPS endpoints.
Expand Down
33 changes: 6 additions & 27 deletions hack/deploy.sh
@@ -1,33 +1,12 @@
#!/bin/bash

arch_list="amd64 arm arm64 ppc64le s390x"
arch_list=(amd64 arm arm64 ppc64le s390x)
manifest="kubernetesui/metrics-scraper";
manifest_list="";

# Concat arch_list with ,
platforms=$(IFS=,; echo "${arch_list[*]}")

for i in ${arch_list}; do
# If it's a tagged release, use the tag
# Otherwise, assume it's HEAD and push to latest
container="${manifest}-${i}:${TRAVIS_TAG:="latest"}"
image_name="${manifest}:${TRAVIS_TAG:="latest"}"

echo "--- docker build --no-cache --build-arg GOARCH=${i} -t ${container} .";
docker build --no-cache --build-arg GOARCH=${i} -t ${container} .

echo "--- docker push ${container}"
docker push ${container}

manifest_list="${manifest_list} ${container}"
done;

echo "--- docker manifest create --amend ${manifest}:${TRAVIS_TAG:="latest"} ${manifest_list}"
docker manifest create --amend ${manifest}:${TRAVIS_TAG:="latest"} ${manifest_list}

for i in ${arch_list}; do
container="${manifest}-${i}:${TRAVIS_TAG:="latest"}"

echo "--- docker manifest annotate ${manifest}:${TRAVIS_TAG:="latest"} ${container} --os linux --arch ${i}"
docker manifest annotate ${manifest}:${TRAVIS_TAG:="latest"} ${container} --os linux --arch ${i}
done;

echo "--- docker manifest push ${manifest}:${TRAVIS_TAG:="latest"}"
docker manifest push ${manifest}:${TRAVIS_TAG:="latest"}
echo "--- docker buildx build --push --platform $platforms --tag $image_name .";
docker buildx build --push --platform ${platforms} --tag ${image_name} .

0 comments on commit b3f5d8f

Please sign in to comment.