From 62e523742fb74314a14c3192ad03a0a5e52c6ec6 Mon Sep 17 00:00:00 2001 From: Melissa Lee Date: Fri, 18 Feb 2022 16:13:29 -0500 Subject: [PATCH] Build and push p and z-linux images to Docker Hub --- .travis.yml | 36 +++++++++++++++++++++++------------ Dockerfile | 4 +++- scripts/build-manifest.sh | 17 +++++++++++++++-- scripts/build-release.sh | 2 +- scripts/build-releases.sh | 1 + scripts/release-blocklist.txt | 5 ++++- 6 files changed, 48 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index f059b6b44..51a6ddf7f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,9 +27,11 @@ stages: - name: rebuild-e2e-test if: branch = main AND fork = false AND type = cron - name: rebuild-releases - if: branch = main AND fork = false AND type = cron + if: (branch = main OR tag =~ ^v) AND fork = false AND type != cron + - name: rebuild-manifest + if: (branch = main OR tag =~ ^v) AND fork = false AND type != cron - name: rebuild-bundles - if: branch = main AND fork = false AND type = cron + if: (branch = main OR tag =~ ^v) AND fork = false AND type != cron jobs: include: @@ -76,21 +78,31 @@ jobs: os: linux arch: amd64 script: travis_wait 45 make setup test-e2e RELEASE_TARGET="releases" || travis_terminate 1 - # - name: Build releases on ppc64le - # stage: rebuild-releases - # os: linux - # arch: ppc64le - # script: make build-releases RELEASE_TARGET="releases" - # - name: Build releases on s390x - # stage: rebuild-releases - # os: linux - # arch: s390x - # script: make build-releases RELEASE_TARGET="releases" + - name: Build releases on ppc64le + stage: rebuild-releases + os: linux + arch: ppc64le + script: make build-releases RELEASE_TARGET="releases" + - name: Build releases on s390x + stage: rebuild-releases + os: linux + arch: s390x + script: make build-releases RELEASE_TARGET="releases" - name: Build releases on amd64 stage: rebuild-releases os: linux arch: amd64 script: make build-releases RELEASE_TARGET="releases" + - name: Build manifest on ppc64le + stage: rebuild-manifest + os: linux + arch: ppc64le + script: make build-manifest RELEASE_TARGET="releases" + - name: Build manifest on s390x + stage: rebuild-manifest + os: linux + arch: s390x + script: make build-manifest RELEASE_TARGET="releases" # Bundle all non-ignored releases - name: Bundle releases stage: rebuild-bundles diff --git a/Dockerfile b/Dockerfile index 705bdd54f..aa3f32084 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ # Build the manager binary FROM golang:1.16 as builder +ARG GO_ARCH=amd64 + WORKDIR /workspace # Copy the Go Modules manifests COPY go.mod go.mod @@ -19,7 +21,7 @@ COPY common/ common/ COPY utils/ utils/ # Build -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -mod vendor -a -o manager main.go +RUN CGO_ENABLED=0 GOOS=linux GOARCH=$GO_ARCH GO111MODULE=on go build -mod vendor -a -o manager main.go #Build final image diff --git a/scripts/build-manifest.sh b/scripts/build-manifest.sh index 23bd87b95..4f95f3dde 100755 --- a/scripts/build-manifest.sh +++ b/scripts/build-manifest.sh @@ -60,13 +60,25 @@ build_manifest() { local tag="$1" echo "****** Building manifest for: ${tag}" + ## Define current arch variable + case "$(uname -p)" in + "ppc64le") + readonly arch="ppc64le" + ;; + "s390x") + readonly arch="s390x" + ;; + *) + readonly arch="amd64" + ;; + esac + ## try to build manifest but allow failure ## this allows new release builds local target="${IMAGE}:${tag}" - # TODO: Add back in linux/s390x and linux/ppc64le once build platforms are back up # --platforms "linux/amd64,linux/s390x,linux/ppc64le" \ manifest-tool push from-args \ - --platforms "linux/amd64" \ + --platforms "linux/${arch}" \ --template "${target}-ARCH" \ --target "${target}" \ || echo "*** WARN: Target architectures not available" @@ -74,6 +86,7 @@ build_manifest() { # Build manifest for previous releases build_manifests() { + git fetch --tags tags="$(git tag -l)" while read -r tag; do if [[ -z "${tag}" ]]; then diff --git a/scripts/build-release.sh b/scripts/build-release.sh index 83bdcbf17..7b68f7da0 100755 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -83,7 +83,7 @@ build_release() { git checkout -q "${RELEASE}" fi - docker build -t "${full_image}" . + docker build -t "${full_image}" --build-arg GO_ARCH=${arch} . return $? } diff --git a/scripts/build-releases.sh b/scripts/build-releases.sh index 2756d9208..5c7ebcd2a 100755 --- a/scripts/build-releases.sh +++ b/scripts/build-releases.sh @@ -55,6 +55,7 @@ main() { } build_releases() { + git fetch --tags tags="$(git tag -l)" while read -r tag; do if [[ -z "${tag}" ]]; then diff --git a/scripts/release-blocklist.txt b/scripts/release-blocklist.txt index f278bb0da..d3141057a 100644 --- a/scripts/release-blocklist.txt +++ b/scripts/release-blocklist.txt @@ -8,4 +8,7 @@ v0.5.1 v0.6.0 v0.7.0 v0.7.1 - +v0.8.0 +v0.8.0-20211124-0830 +v0.8.0-20211124-1750 +v0.8.0-rc.1 \ No newline at end of file