Add olm to CI builds

This commit is contained in:
Tulir Asokan 2020-05-08 23:53:30 +03:00
parent acc25a02e4
commit edd91510f1
4 changed files with 44 additions and 26 deletions

View file

@ -10,3 +10,6 @@ insert_final_newline = true
[*.{yaml,yml}]
indent_style = space
[.gitlab-ci.yml]
indent_size = 2

View file

@ -3,16 +3,15 @@ stages:
- build docker
- manifest
build:
.build: &build
image: golang:1-alpine
stage: build
tags:
- amd64
cache:
paths:
- .cache
before_script:
- apk add git build-base
- echo "@edge_community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
- apk add git build-base olm-dev@edge_community
- mkdir -p .cache
- export GOPATH="$CI_PROJECT_DIR/.cache"
script:
@ -22,31 +21,44 @@ build:
- mautrix-whatsapp
- example-config.yaml
build docker amd64:
.build-docker: &build-docker
image: docker:stable
stage: build docker
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-$DOCKER_ARCH . --file Dockerfile.ci
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-$DOCKER_ARCH
- docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-$DOCKER_ARCH
build amd64:
<<: *build
tags:
- amd64
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 . --file Dockerfile.ci
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
- docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
build docker arm64:
image: docker:stable
stage: build docker
build arm64:
<<: *build
tags:
- arm64
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64 .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64
- docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64
build docker amd64:
<<: *build-docker
tags:
- amd64
dependencies:
- build amd64
variables:
DOCKER_ARCH: amd64
build docker arm64:
<<: *build-docker
tags:
- arm64
dependencies:
- build arm64
variables:
DOCKER_ARCH: arm64
manifest:
stage: manifest

View file

@ -1,6 +1,7 @@
FROM golang:1.12-alpine AS builder
FROM golang:1-alpine AS builder
RUN apk add --no-cache git ca-certificates build-base su-exec
RUN echo "@edge_community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN apk add --no-cache git ca-certificates build-base su-exec olm-dev@edge_community
WORKDIR /build
COPY go.mod go.sum /build/
@ -14,7 +15,8 @@ FROM alpine:latest
ENV UID=1337 \
GID=1337
RUN apk add --no-cache su-exec ca-certificates
RUN echo "@edge_community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN apk add --no-cache su-exec ca-certificates olm@edge_community
COPY --from=builder /usr/bin/mautrix-whatsapp /usr/bin/mautrix-whatsapp
COPY --from=builder /build/example-config.yaml /opt/mautrix-whatsapp/example-config.yaml

View file

@ -3,7 +3,8 @@ FROM alpine:latest
ENV UID=1337 \
GID=1337
RUN apk add --no-cache su-exec ca-certificates
RUN echo "@edge_community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN apk add --no-cache su-exec ca-certificates olm@edge_community
ARG EXECUTABLE=./mautrix-whatsapp
COPY $EXECUTABLE /usr/bin/mautrix-whatsapp