Skip to content

Commit

Permalink
add multi-arch builds for upstream and stable skopeo image via Travis
Browse files Browse the repository at this point in the history
Travis is used, as it has native hardware to run the build for many
architectures (amd64, s390x, ppc64le). Docker is used as build and
manifest tool. `quay.io/skopeo/upstream:ma`, `quay.io/skopeo/stable:ma`
and `quay.io/containers/skopeo:ma` are specified as target multi-arch
upstream image.
Travis config file has 3 stages:
- local-build to do the local test for linux/amd64 and osx, as it was in
the initial code
- image-build-push to build and push images for specific architectures
(amd64, s390x, ppc64le)
- multi-arch-manifest-push to create and push manifest for multi-arch
image - `quay.io/skopeo/upstream:master`, `quay.io/skopeo/stable:v1.2.0`
and `quay.io/containers/skopeo:v1.2.0`

2 last stages are not done for pull request.

2 env variables specified in Travis settings are expected - QUAY_USERNAME and
QUAY_PASSWORD to push the images to quay.io.
As a result multi-arch images for 3 architectures are published.

Signed-off-by: Yulia Gaponenko <[email protected]>
  • Loading branch information
barthy1 committed Oct 28, 2020
1 parent 9bcae70 commit 83003c7
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 19 deletions.
85 changes: 66 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,74 @@
language: go

matrix:
include:
- os: linux
sudo: required
services:
- docker
- os: osx

go:
- 1.13.x

notifications:
email: false

install:
# Ideally, the (brew update) should not be necessary and Travis would have fairly
# frequenstly updated OS images; that’s not been the case historically.
# In particular, explicitly unlink python@2, which has been removed from Homebrew
# since the last OS image build (as of July 2020), but the Travis OS still
# contains it, and it prevents updating of Python 3.
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update && brew unlink python@2 && brew install gpgme ; fi

script:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then hack/travis_osx.sh ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make vendor && ./hack/tree_status.sh && make local-cross && make check ; fi
env:
global:
- REGISTRY=quay.io

x_base_steps:
- &image-build-push
services:
- docker
os: linux
script:
- SOURCE_TYPE=upstream REPO=skopeo/upstream TAG=master make build-push-arch-container
- SOURCE_TYPE=stable REPO=skopeo/stable TAG=v1.2.0 EXTRA_REPO=containers/skopeo make build-push-arch-container

stages:
- local-build
- name: image-build-push
if: type != pull_request AND branch = master
- name: multi-arch-manifest-push
if: type != pull_request AND branch = master

jobs:
allow_failures:
- if: arch in (s390x, ppc64le)
include:
- stage: local-build
<<: *local-build
name: local build for osx
os: osx
install:
# Ideally, the (brew update) should not be necessary and Travis would have fairly
# frequently updated OS images; that's not been the case historically.
# In particular, explicitly unlink python@2, which has been removed from Homebrew
# since the last OS image build (as of July 2020), but the Travis OS still
# contains it, and it prevents updating of Python 3.
- brew update && brew unlink python@2 && brew install gpgme
script:
- hack/travis_osx.sh
- stage: local-build
<<: *local-build
name: local build for linux
os: linux
services:
- docker
script:
- make vendor && ./hack/tree_status.sh && make local-cross && make check

- stage: image-build-push
<<: *image-build-push
name: image for amd64
arch: amd64

- stage: image-build-push
<<: *image-build-push
name: image for s390x
arch: s390x

- stage: image-build-push
<<: *image-build-push
name: image for ppc64le
arch: ppc64le

- stage: multi-arch-manifest-push
os: linux
script:
- SOURCE_TYPE=upstream REPO=skopeo/upstream TAG=master make push-ma-manifest
- SOURCE_TYPE=stable REPO=skopeo/stable TAG=v1.2.0 EXTRA_REPO=containers/skopeo make push-ma-manifest
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ ifeq ($(DISABLE_CGO), 1)
override BUILDTAGS = exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp
endif

ARCHES=amd64 s390x ppc64le
MA_IMAGE := $(REGISTRY)/$(REPO):$(TAG)
ARCH_IMAGE := $(MA_IMAGE)-$(GOARCH)
ifneq ($(EXTRA_REPO),)
EXTRA_MA_IMAGE := $(REGISTRY)/$(EXTRA_REPO):$(TAG)
EXTRA_ARCH_IMAGE := $(EXTRA_MA_IMAGE)-$(GOARCH)
endif

# make all DEBUG=1
# Note: Uses the -N -l go compiler options to disable compiler optimizations
# and inlining. Using these build options allows you to subsequently
Expand Down Expand Up @@ -135,6 +143,27 @@ local-cross: bin/skopeo.darwin.amd64 bin/skopeo.linux.arm bin/skopeo.linux.arm64
build-container:
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -t "$(IMAGE)" .

# Build and ush container specific to arch
build-push-arch-container:
${CONTAINER_RUNTIME} build -t "${ARCH_IMAGE}" contrib/skopeoimage/${SOURCE_TYPE}
echo "${QUAY_PASSWORD}" | ${CONTAINER_RUNTIME} login ${REGISTRY} -u "${QUAY_USERNAME}" --password-stdin
${CONTAINER_RUNTIME} push "${ARCH_IMAGE}"
ifneq ($(EXTRA_REPO),)
${CONTAINER_RUNTIME} tag "${ARCH_IMAGE}" "${EXTRA_ARCH_IMAGE}"
${CONTAINER_RUNTIME} push "${EXTRA_ARCH_IMAGE}"
endif

# Push manifest to make multi-arch image
push-ma-manifest:
echo "${QUAY_PASSWORD}" | docker login ${REGISTRY} -u "${QUAY_USERNAME}" --password-stdin
sudo chmod 0755 /etc/docker
DOCKER_CLI_EXPERIMENTAL="enabled" docker manifest create "${MA_IMAGE}" $(foreach arch,${ARCHES}, ${MA_IMAGE}-${arch})
DOCKER_CLI_EXPERIMENTAL="enabled" docker manifest push --purge "${MA_IMAGE}"
ifneq ($(EXTRA_REPO),)
DOCKER_CLI_EXPERIMENTAL="enabled" docker manifest create "${EXTRA_MA_IMAGE}" $(foreach arch,${ARCHES}, ${EXTRA_MA_IMAGE}-${arch})
DOCKER_CLI_EXPERIMENTAL="enabled" docker manifest push --purge "${EXTRA_MA_IMAGE}"
endif

$(MANPAGES): %: %.md
sed -e 's/\((skopeo.*\.md)\)//' -e 's/\[\(skopeo.*\)\]/\1/' $< | $(GOMD2MAN) -in /dev/stdin -out $@

Expand Down

0 comments on commit 83003c7

Please sign in to comment.