Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable multiarch builds #135

Merged
merged 1 commit into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
os: linux
services: docker
dist: focal
language: go
go: stable

env:
global:
- IMAGE1: quay.io/konveyor/velero
- IMAGE2: quay.io/konveyor/velero-restic-restore-helper
- DEFAULT_BRANCH: konveyor-dev
- DOCKERFILE1: Dockerfile.ubi
- DOCKERFILE2: Dockerfile-velero-restic-restore-helper.ubi
- DOCKER_CLI_EXPERIMENTAL: enabled
- GOPROXY: https://goproxy.io,direct

before_install:
- |
if [ "${TRAVIS_BRANCH}" == "${DEFAULT_BRANCH}" ]; then
export TAG=latest
else
export TAG="${TRAVIS_BRANCH}"
fi

# Builds routinely fail due to download failures inside alternate arch docker containers
# Here we are downloading outside the docker container and copying the deps in
# Also use -v for downloads/builds to stop no output failures from lxd env buffering.
before_script:
- go mod vendor -v
- git clone https://github.com/konveyor/restic -b konveyor-dev
- pushd restic; go mod vendor -v; popd
- sed -i 's|-mod=mod|-mod=vendor|g' ${DOCKERFILE1}
- sed -i 's|-mod=mod|-mod=vendor|g' ${DOCKERFILE2}
- sed -i 's|go build|go build -v|g' ${DOCKERFILE1}
- sed -i 's|go build|go build -v|g' ${DOCKERFILE2}
- sed -i 's|^RUN mkdir -p \$APP_ROOT/src/github.com/restic \\$|COPY --chown=1001 restic/ $APP_ROOT/src/github.com/restic/restic|g' ${DOCKERFILE1}
- sed -i 's|&& cd \$APP_ROOT/src/github.com/restic \\$||g' ${DOCKERFILE1}
- sed -i 's|&& git clone https://github.com/konveyor/restic -b konveyor-dev$||g' ${DOCKERFILE1}

script:
- docker build -t ${IMAGE1}:${TAG}-${TRAVIS_ARCH} -f ${DOCKERFILE1} .
- docker build -t ${IMAGE2}:${TAG}-${TRAVIS_ARCH} -f ${DOCKERFILE2} .
- if [ -n "${QUAY_ROBOT}" ]; then docker login quay.io -u "${QUAY_ROBOT}" -p ${QUAY_TOKEN}; fi
- if [ -n "${QUAY_ROBOT}" ]; then docker push ${IMAGE1}:${TAG}-${TRAVIS_ARCH}; fi
- if [ -n "${QUAY_ROBOT}" ]; then docker push ${IMAGE2}:${TAG}-${TRAVIS_ARCH}; fi

jobs:
include:
- stage: build images
arch: ppc64le
- arch: s390x
- arch: arm64
- arch: amd64
- stage: push manifest
language: shell
arch: amd64
before_script: []
script:
- |
if [ -n "${QUAY_ROBOT}" ]; then
docker login quay.io -u "${QUAY_ROBOT}" -p ${QUAY_TOKEN}
docker manifest create \
${IMAGE1}:${TAG} \
${IMAGE1}:${TAG}-amd64 \
${IMAGE1}:${TAG}-ppc64le \
${IMAGE1}:${TAG}-s390x \
${IMAGE1}:${TAG}-aarch64
docker manifest create \
${IMAGE2}:${TAG} \
${IMAGE2}:${TAG}-amd64 \
${IMAGE2}:${TAG}-ppc64le \
${IMAGE2}:${TAG}-s390x \
${IMAGE2}:${TAG}-aarch64
docker manifest push ${IMAGE1}:${TAG}
docker manifest push ${IMAGE2}:${TAG}
fi
2 changes: 1 addition & 1 deletion Dockerfile-velero-restic-restore-helper.ubi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.access.redhat.com/ubi8/go-toolset:1.14.7 AS builder
FROM quay.io/konveyor/builder:latest AS builder
ENV GOPATH=$APP_ROOT
COPY . $APP_ROOT/src/github.com/vmware-tanzu/velero
WORKDIR $APP_ROOT/src/github.com/vmware-tanzu/velero
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.ubi
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# TODO! Find a real ubi8 image for golang 1.16
FROM quay.io/app-sre/boilerplate:image-v2.1.0 AS builder
FROM quay.io/konveyor/builder:latest AS builder
ENV GOPATH=$APP_ROOT
COPY . /go/src/github.com/vmware-tanzu/velero
WORKDIR /go/src/github.com/vmware-tanzu/velero
RUN CGO_ENABLED=0 GOOS=linux go build -a -mod=mod -ldflags '-extldflags "-static" -X github.com/vmware-tanzu/velero/pkg/buildinfo.Version=konveyor-dev' -o /go/src/velero github.com/vmware-tanzu/velero/cmd/velero

FROM registry.access.redhat.com/ubi8/go-toolset:1.14.7 AS restic-builder
FROM quay.io/konveyor/builder:latest AS restic-builder
ENV GOPATH=$APP_ROOT
RUN mkdir -p $APP_ROOT/src/github.com/restic \
&& cd $APP_ROOT/src/github.com/restic \
Expand Down