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}] [*.{yaml,yml}]
indent_style = space indent_style = space
[.gitlab-ci.yml]
indent_size = 2

View file

@ -3,16 +3,15 @@ stages:
- build docker - build docker
- manifest - manifest
build: .build: &build
image: golang:1-alpine image: golang:1-alpine
stage: build stage: build
tags:
- amd64
cache: cache:
paths: paths:
- .cache - .cache
before_script: 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 - mkdir -p .cache
- export GOPATH="$CI_PROJECT_DIR/.cache" - export GOPATH="$CI_PROJECT_DIR/.cache"
script: script:
@ -22,31 +21,44 @@ build:
- mautrix-whatsapp - mautrix-whatsapp
- example-config.yaml - example-config.yaml
build docker amd64: .build-docker: &build-docker
image: docker:stable image: docker:stable
stage: build docker 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: tags:
- amd64 - 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: build arm64:
image: docker:stable <<: *build
stage: build docker
tags: tags:
- arm64 - arm64
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY build docker amd64:
script: <<: *build-docker
- docker pull $CI_REGISTRY_IMAGE:latest || true tags:
- docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64 . - amd64
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64 dependencies:
- docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64 - build amd64
variables:
DOCKER_ARCH: amd64
build docker arm64:
<<: *build-docker
tags:
- arm64
dependencies:
- build arm64
variables:
DOCKER_ARCH: arm64
manifest: manifest:
stage: 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 WORKDIR /build
COPY go.mod go.sum /build/ COPY go.mod go.sum /build/
@ -14,7 +15,8 @@ FROM alpine:latest
ENV UID=1337 \ ENV UID=1337 \
GID=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 /usr/bin/mautrix-whatsapp /usr/bin/mautrix-whatsapp
COPY --from=builder /build/example-config.yaml /opt/mautrix-whatsapp/example-config.yaml 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 \ ENV UID=1337 \
GID=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 ARG EXECUTABLE=./mautrix-whatsapp
COPY $EXECUTABLE /usr/bin/mautrix-whatsapp COPY $EXECUTABLE /usr/bin/mautrix-whatsapp