This repository has been archived by the owner on Jul 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use buildx for cross-platform builds
Use Docker buildx build tooling to create multi-arch manifest instead of manually adding images. Test build: https://hub.docker.com/r/jamesnelson/metrics-scraper/tags Signed-off-by: James Tumber <james.tumber@ibm.com>
- Loading branch information
Showing
2 changed files
with
13 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} . |