-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add multi-arch image(amd64 and s390x) build and publish for alpine/gi…
…t image - build script was extended to build and publish images with arch information in tag (based on TRAVIS_CPU_ARCH env variable value), default is amd64 - in build script NEXT_TAG is generated only for amd64, because container image to get the value is amd64 only - alpine/semver:5.5.0. For s390x this value is stored in Travis workspace (or local file called tag.txt) - git push will work for amd64 only (to avoid push duplicates) - multi-arch-image script was added to create and push multi-arch manifest to dockerhub, joining together separate images for different architectures. At this moment amd64 and s390x are added. - Travis configuration file was extended to have 3 stages: - build amd64 images - build s390x images - generate multi-arch images based on previous stages - workspace usage was added to Travis config to persist NEXT_TAG data, as this value can be received only for amd64 case. s390x is just used it after from workspace tag.txt file Signed-off-by: Yulia Gaponenko <[email protected]>
- Loading branch information
Showing
3 changed files
with
94 additions
and
24 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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Prerequisite | ||
# Make sure you set secret enviroment variables in Travis CI | ||
# DOCKER_USERNAME | ||
# DOCKER_PASSWORD | ||
|
||
set -e | ||
|
||
function get_arch_images(){ | ||
image=$1; shift || fatal "usage error" | ||
tag=$1; shift || fatal "usage error" | ||
archs="amd64 s390x" | ||
for arch in $archs; do | ||
if [[ "$(docker pull ${image}:${tag}-${arch} >/dev/null 2>&1 ; echo $?)" == 0 ]]; then | ||
echo "${image}:${tag}-${arch} " | ||
fi | ||
done | ||
} | ||
|
||
image="alpine/git" | ||
if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == false ]]; then | ||
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD | ||
NEXT_TAG=$(cat tag.txt) | ||
VERSION=$(docker run -i --rm ${image}:latest-amd64 version|awk '{print $NF}') | ||
#create and push multi-arch 3 images - latest, ${NEXT_TAG} and v${VERSION} | ||
DOCKER_CLI_EXPERIMENTAL="enabled" docker manifest create ${image}:${NEXT_TAG} $(get_arch_images ${image} ${NEXT_TAG}) | ||
DOCKER_CLI_EXPERIMENTAL="enabled" docker manifest push --purge ${image}:${NEXT_TAG} | ||
DOCKER_CLI_EXPERIMENTAL="enabled" docker manifest create ${image}:latest $(get_arch_images ${image} "latest") | ||
DOCKER_CLI_EXPERIMENTAL="enabled" docker manifest push --purge ${image}:latest | ||
DOCKER_CLI_EXPERIMENTAL="enabled" docker manifest create ${image}:v${VERSION} $(get_arch_images ${image} v${VERSION}) | ||
DOCKER_CLI_EXPERIMENTAL="enabled" docker manifest push --purge ${image}:v${VERSION} | ||
fi | ||
|
||
if [[ "$TRAVIS_BRANCH" == "feature/non-root" && "$TRAVIS_PULL_REQUEST" == false ]]; then | ||
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD | ||
#create and push multi-arch 2 images - user and v${VERSION}-user | ||
DOCKER_CLI_EXPERIMENTAL="enabled" docker manifest create ${image}:user $(get_arch_images ${image} "user") | ||
DOCKER_CLI_EXPERIMENTAL="enabled" docker manifest push --purge ${image}:user | ||
DOCKER_CLI_EXPERIMENTAL="enabled" docker manifest create ${image}:v${VERSION}-user $(get_arch_images ${image} v${VERSION}-user) | ||
DOCKER_CLI_EXPERIMENTAL="enabled" docker manifest push --purge ${image}:v${VERSION}-user | ||
fi |