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

multiarch build support on Travis and GitLab-CI #304

Merged
merged 1 commit into from
Jan 29, 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
67 changes: 25 additions & 42 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,14 @@
stages:
- build
- test
- container

before_script:
before_script: &before_script
- apk update
- apk --no-cache upgrade
- apk --no-cache add gcc git libc-dev libc-utils libgcc linux-headers make bash musl-dev musl-utils ncurses-dev pcre2 pkgconf scanelf wget zlib

.build:otp: &build_otp
stage: build
image: erlang
artifacts:
untracked: true
paths:
- _build
script:
# Prepare environmental variables
- wget https://s3.amazonaws.com/rebar3/rebar3 && chmod a+x rebar3
- ./rebar3 compile

build:otp-22.3:
<<: *build_otp
image: erlang:22.3.4.12-alpine

build:otp-23.0:
<<: *build_otp
allow_failure: true
image: erlang:23.0.4-alpine

build:otp-23.1:
<<: *build_otp
allow_failure: true
image: erlang:23.1.2.0-alpine
- |
apk --no-cache add gcc git libc-dev libc-utils libgcc linux-headers make bash \
musl-dev musl-utils ncurses-dev pcre2 pkgconf scanelf wget \
zlib curl

.check:otp: &check_otp
stage: test
Expand Down Expand Up @@ -61,46 +37,53 @@ build:otp-23.1:
- ip addr add fd96:dcd2:efdb:41c3::30/64 dev lo
- ip addr add fd96:dcd2:efdb:41c3::40/64 dev lo
- ip addr add fd96:dcd2:efdb:41c3::50/64 dev lo
- ./rebar3 do xref
- ./rebar3 do ct
- rebar3 xref
vkatsuba marked this conversation as resolved.
Show resolved Hide resolved
- rebar3 ct

check:otp-22.3:
<<: *check_otp
image: erlang:22.3.4.12-alpine
dependencies:
- build:otp-22.3

check:otp-23.0:
<<: *check_otp
image: erlang:23.0.4-alpine
dependencies:
- build:otp-23.0

check:otp-23.1:
<<: *check_otp
image: erlang:23.1.2.0-alpine
dependencies:
- build:otp-23.1

docker:
image: docker:git
image: jdrouet/docker-with-buildx:stable
stage: container
dependencies: []
variables:
REGISTRY: "quay.io"
BUILD_IMAGE: "travelping/ergw-c-node"
services:
- docker:dind
- linuxkit/binfmt:v0.8
script:
- docker version
- docker buildx ls
- docker buildx inspect --bootstrap
- export CI_COMMIT_DESCRIBE=$(git describe)
- |
case "$CI_COMMIT_REF_NAME" in
master | stable/*) export LABELS="";;
*) export LABELS="--label quay.expires-after=7d";;
esac
- |
if [ $CI_COMMIT_REF_NAME == "master" ] ; then
export TAGS="-t ${REGISTRY}/${BUILD_IMAGE}:v${CI_COMMIT_DESCRIBE}"
else
export TAGS="-t ${REGISTRY}/${BUILD_IMAGE}:${CI_COMMIT_REF_SLUG}_v${CI_COMMIT_DESCRIBE}"
fi
- docker login -u ${QUAY_USER_ID} -p ${QUAY_TOKEN} ${REGISTRY}
- docker build ${LABELS} -t ${REGISTRY}/${BUILD_IMAGE}:$CI_COMMIT_SHA -t ${REGISTRY}/${BUILD_IMAGE}:$CI_COMMIT_REF_SLUG\_$CI_COMMIT_DESCRIBE -f docker/Dockerfile .
- docker push ${REGISTRY}/${BUILD_IMAGE}:$CI_COMMIT_SHA
- docker push ${REGISTRY}/${BUILD_IMAGE}:$CI_COMMIT_REF_SLUG\_$CI_COMMIT_DESCRIBE
- if [ $CI_COMMIT_REF_NAME == "master" ] ; then docker tag ${REGISTRY}/${BUILD_IMAGE}:$CI_COMMIT_SHA ${REGISTRY}/${BUILD_IMAGE}:latest ; docker push ${REGISTRY}/${BUILD_IMAGE}:latest ; fi
- |
docker buildx build \
-f docker/Dockerfile \
${TAGS} \
${LABELS} \
--platform=linux/arm64,linux/amd64 \
--push --no-cache .
when: always
64 changes: 42 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
sudo: required
arch: amd64
dist: bionic
dist: focal
group: edge
services:
- docker
git:
Expand All @@ -9,17 +10,27 @@ git:
language: erlang

otp_release:
- 22.3.4
- 23.0.4
- 23.0
- 23.1.2

install: "true"

env:
global:
- BUILDX_VER=v0.5.1
- BUILD_IMAGE="ergw/ergw-c-node"
- DOCKER_USERNAME="ergwci"
- secure: "JpJScMSO4Sqj4odjSFEpshqFk93ZyVkhMNNc9xh2yfRpkHFNXXnhLYhKLA/nr1gcd1f9jnWz++1cqa4MQXRGanDT3+iGNO12R/M3ZVT26ywV0QEmj6z/acsv5wC34hje8/zWAgKWBsIxswFVT+RRPzNOQNVq6JPLZSp014qX5P+ChwmPeCG2kY/od9fsftp7ZjqyhqOOlXGJeEInvF5SD1RqnVMYP2OEQnGQyAHg9aoczO1cZnpZSRQFTqtDzwG1lp21oqsk2IVSCTqXdD1+GNSZCV4oHddXwGJICN9klSHUnxKb7/rFwbVh090+wP7PA+4eqCOOCGIIePFRMDiux6wX07p4wFhtt6/ZGmOs+1kV9ZR4W9FP+rv/0LUlMpmd52WoWkn1kGA/fEr/Jff3n+PjcXd25W/ASeKciahhvXLudeoauP3/wB/3gfFBSnaVR1FvU10rAdL9X+W13z+UiL5C+1qDRjs/6OFpq0T4KfWkxxy1+9eG5J5u8gsKQ+1THvSerddGX77ZvnHu1m1A8z8fGF6toMUvR7EJvr/wpeVwRO/SOB03JYUYdeRnGYXYbOt4UE2ovh/g34mnxQptKW3Pk9aqT2x/Uamsn661tRJL7kVCGOnIUohh4Ynf2tniLbWsRorZlltcIxK4kaKuNfsV/gpvAaguDkeY0ul5AqM="

before_install:
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo apt-get update
- sudo apt-get -y install binfmt-support zip qemu-user-static
- |
mkdir -vp ~/.docker/cli-plugins/ ~/dockercache
curl --silent -L "https://github.com/docker/buildx/releases/download/${BUILDX_VER}/buildx-${BUILDX_VER}.linux-amd64" > ~/.docker/cli-plugins/docker-buildx
chmod a+x ~/.docker/cli-plugins/docker-buildx

before_script:
- wget https://s3.amazonaws.com/rebar3/rebar3
- chmod u+x ./rebar3
Expand Down Expand Up @@ -49,31 +60,40 @@ script:
- ip -br addr
- source test/env.sh
- ./rebar3 compile
- ./rebar3 do xref, ct
- ./rebar3 xref
- ./rebar3 ct
- (./rebar3 as test do coveralls send || /bin/true)
- (cd _build/test/logs/; zip -1r ../../../ct-logs.zip . )

.build.docker: &build_docker
stage: docker
otp_release: 23.1.2
script:
- ./rebar3 deps
- docker version
- docker buildx create --use
- docker buildx ls
- docker buildx inspect --bootstrap
- ls -al /proc/sys/fs/binfmt_misc/
- docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
- |
GIT_DESCRIBE=`git describe`
TAG=`if [ "$TRAVIS_EVENT_TYPE" == "pull_request" ]; then echo PR-$TRAVIS_PULL_REQUEST_BRANCH\_$TRAVIS_PULL_REQUEST_SHA ; else echo $TRAVIS_BRANCH\_$GIT_DESCRIBE ; fi`
TAG=`echo "$TAG" | sed -e 's,/,-,g'`
TAGS="-t $BUILD_IMAGE:$TAG"
if [ "$TAG" == "master" ]; then TAGS="$TAGS -t $BUILD_IMAGE:latest"; fi
echo "TAGS: $TAGS"
docker buildx build -f docker/Dockerfile --platform=linux/arm64,linux/amd64 $TAGS --push --no-cache .

jobs:
include:
-
# this fails, disable it for the moment
# - dist: xenial
# arch: arm64
# otp_release: 22.0.5
- stage: docker
otp_release: 22.3.4
script:
- docker build -t $BUILD_IMAGE -f docker/Dockerfile .
after_success:
- docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
- export GIT_DESCRIBE=`git describe`
- export TAG=`if [ "$TRAVIS_EVENT_TYPE" == "pull_request" ]; then echo PR-$TRAVIS_PULL_REQUEST_BRANCH\_$TRAVIS_PULL_REQUEST_SHA ; else echo $TRAVIS_BRANCH\_$GIT_DESCRIBE ; fi`
- export TAG=`echo "$TAG" | sed -e 's,/,-,g'`
- echo "Docker image $BUILD_IMAGE:$TAG"
- if [ "$TAG" == "master" ]; then export TAG="latest"; fi
- docker tag $BUILD_IMAGE $BUILD_IMAGE:$TAG
- docker push $BUILD_IMAGE:$TAG
- echo "docker push done"
- dist: focal
arch: arm64-graviton2
group: edge
virt: vm
otp_release: 23.1.2
- <<: *build_docker

addons:
artifacts:
Expand Down