Commit 284fe7f1 authored by Tulir Asokan's avatar Tulir Asokan 🐈

Build static executables with olm using gomuks-build-docker

parent 592b0862
Pipeline #1700 passed with stages
in 2 minutes and 46 seconds
......@@ -4,17 +4,15 @@ stages:
- manifest
.build: &build
image: golang:1-alpine
stage: build
cache:
paths:
- .cache
before_script:
- apk add build-base olm-dev && apk policy olm-dev
- mkdir -p .cache
- export GOPATH="$CI_PROJECT_DIR/.cache"
- export GOCACHE="$CI_PROJECT_DIR/.cache/build"
- export GO_LDFLAGS="-X main.Tag=$CI_COMMIT_TAG -X main.Commit=$CI_COMMIT_SHA -X 'main.BuildTime=`date '+%b %_d %Y, %H:%M:%S'`'"
- export GO_LDFLAGS="-linkmode external -extldflags -static -X main.Tag=$CI_COMMIT_TAG -X main.Commit=$CI_COMMIT_SHA -X 'main.BuildTime=`date '+%b %_d %Y, %H:%M:%S'`'"
script:
- go build -ldflags "$GO_LDFLAGS" -o mautrix-whatsapp
artifacts:
......@@ -29,47 +27,21 @@ stages:
- 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 --build-arg TARGETARCH=$DOCKER_ARCH --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-$DOCKER_ARCH . --file Dockerfile.ci
- 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 static:
image: golang:1-alpine
stage: build
tags:
- amd64
cache:
paths:
- .cache
before_script:
- mkdir -p .cache
- export GOPATH="$CI_PROJECT_DIR/.cache"
- export GOCACHE="$CI_PROJECT_DIR/.cache/build"
- export GO_LDFLAGS="-X main.Tag=$CI_COMMIT_TAG -X main.Commit=$CI_COMMIT_SHA -X 'main.BuildTime=`date '+%b %_d %Y, %H:%M:%S'`'"
variables:
CGO_ENABLED: 0
script:
- GOOS=linux GOARCH=amd64 go build -ldflags "$GO_LDFLAGS" -o mautrix-whatsapp_linux_amd64
- GOOS=linux GOARCH=arm64 go build -ldflags "$GO_LDFLAGS" -o mautrix-whatsapp_linux_arm64
- GOOS=linux GOARCH=arm go build -ldflags "$GO_LDFLAGS" -o mautrix-whatsapp_linux_arm
- GOOS=linux GOARCH=386 go build -ldflags "$GO_LDFLAGS" -o mautrix-whatsapp_linux_386
artifacts:
paths:
- mautrix-whatsapp_linux_amd64
- mautrix-whatsapp_linux_arm64
- mautrix-whatsapp_linux_arm
- mautrix-whatsapp_linux_386
- example-config.yaml
build amd64:
<<: *build
tags:
- amd64
image: dock.mau.dev/tulir/gomuks-build-docker:linux-amd64
build arm64:
<<: *build
tags:
- arm64
image: dock.mau.dev/tulir/gomuks-build-docker:linux-arm64
build arm:
<<: *build
image: dock.mau.dev/tulir/gomuks-build-docker:linux-arm
build docker amd64:
<<: *build-docker
......
FROM alpine:3.12
ARG TARGETARCH=amd64
ARG YQ_DOWNLOAD_ADDR=https://github.com/mikefarah/yq/releases/download/3.3.2/yq_linux_${TARGETARCH}
RUN echo $'\
@edge http://dl-cdn.alpinelinux.org/alpine/edge/main\n\
@edge http://dl-cdn.alpinelinux.org/alpine/edge/testing\n\
@edge http://dl-cdn.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories
ENV UID=1337 \
GID=1337
RUN apk add --no-cache ffmpeg su-exec ca-certificates olm bash jq curl && \
curl -sLo yq ${YQ_DOWNLOAD_ADDR} && \
chmod +x yq && mv yq /usr/bin/yq
RUN apk add --no-cache ffmpeg su-exec ca-certificates bash jq curl yq@edge
ARG EXECUTABLE=./mautrix-whatsapp
COPY $EXECUTABLE /usr/bin/mautrix-whatsapp
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment