Add arm64 docker builds to CI

This commit is contained in:
Tulir Asokan 2020-02-25 22:59:39 +02:00
parent 260555b69c
commit 685e6a3be0
2 changed files with 48 additions and 28 deletions

View file

@ -1,11 +1,13 @@
stages: stages:
- build - build
- build docker - build docker
- push docker - manifest
build: build amd64:
image: golang:1-alpine image: golang:1-alpine
stage: build stage: build
tags:
- amd64
cache: cache:
paths: paths:
- .cache - .cache
@ -17,45 +19,62 @@ build:
- go build -o mautrix-whatsapp - go build -o mautrix-whatsapp
artifacts: artifacts:
paths: paths:
- mautrix-whatsapp - mautrix-whatsapp-amd64
- example-config.yaml - example-config.yaml
build docker: build arm64:
image: golang:1-alpine
stage: build
tags:
- arm64
cache:
paths:
- .cache
before_script:
- apk add git build-base
- mkdir -p .cache
- export GOPATH="$CI_PROJECT_DIR/.cache"
script:
- go build -o mautrix-whatsapp
artifacts:
paths:
- mautrix-whatsapp-arm64
- example-config.yaml
build docker amd64:
image: docker:stable image: docker:stable
stage: build docker stage: build docker
tags:
- amd64
before_script: before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script: script:
- docker pull $CI_REGISTRY_IMAGE:latest || true - docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA . --file Dockerfile.ci - docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 . --file Dockerfile.ci --build-args EXECUTABLE=./mautrix-whatsapp-amd64
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
- docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
push latest: build docker arm64:
image: docker:stable image: docker:stable
stage: push docker stage: build docker
only: tags:
- master - arm64
variables:
GIT_STRATEGY: none
before_script: before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script: script:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA - docker pull $CI_REGISTRY_IMAGE:latest || true
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest - docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 . --file Dockerfile.ci --build-args EXECUTABLE=./mautrix-whatsapp-arm64
- docker push $CI_REGISTRY_IMAGE:latest - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
dependencies: [] - docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64
push tag: manifest:
image: docker:stable stage: manifest
stage: push docker
except:
- master
variables:
GIT_STRATEGY: none
before_script: before_script:
- "mkdir -p $HOME/.docker && echo '{\"experimental\": \"enabled\"}' > $HOME/.docker/config.json"
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script: script:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME - if [ $CI_COMMIT_BRANCH == "master" ]; then docker manifest create $CI_REGISTRY_IMAGE:latest $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64 && docker manifest push $CI_REGISTRY_IMAGE:latest; fi
dependencies: [] - if [ $CI_COMMIT_BRANCH != "master" ]; then docker manifest create $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64 && docker manifest push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME; fi
- docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64

View file

@ -5,7 +5,8 @@ ENV UID=1337 \
RUN apk add --no-cache su-exec ca-certificates RUN apk add --no-cache su-exec ca-certificates
COPY ./mautrix-whatsapp /usr/bin/mautrix-whatsapp ARG EXECUTABLE=./mautrix-whatsapp
COPY $EXECUTABLE /usr/bin/mautrix-whatsapp
COPY ./example-config.yaml /opt/mautrix-whatsapp/example-config.yaml COPY ./example-config.yaml /opt/mautrix-whatsapp/example-config.yaml
COPY ./docker-run.sh /docker-run.sh COPY ./docker-run.sh /docker-run.sh
VOLUME /data VOLUME /data