Build static executables with olm using gomuks-build-docker
This commit is contained in:
parent
592b0862ce
commit
284fe7f1a6
@ -4,17 +4,15 @@ stages:
|
|||||||
- manifest
|
- manifest
|
||||||
|
|
||||||
.build: &build
|
.build: &build
|
||||||
image: golang:1-alpine
|
|
||||||
stage: build
|
stage: build
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- .cache
|
- .cache
|
||||||
before_script:
|
before_script:
|
||||||
- apk add build-base olm-dev && apk policy olm-dev
|
|
||||||
- mkdir -p .cache
|
- mkdir -p .cache
|
||||||
- export GOPATH="$CI_PROJECT_DIR/.cache"
|
- export GOPATH="$CI_PROJECT_DIR/.cache"
|
||||||
- export GOCACHE="$CI_PROJECT_DIR/.cache/build"
|
- 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:
|
script:
|
||||||
- go build -ldflags "$GO_LDFLAGS" -o mautrix-whatsapp
|
- go build -ldflags "$GO_LDFLAGS" -o mautrix-whatsapp
|
||||||
artifacts:
|
artifacts:
|
||||||
@ -29,47 +27,21 @@ stages:
|
|||||||
- 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 --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 push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-$DOCKER_ARCH
|
||||||
- docker rmi $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 amd64:
|
||||||
<<: *build
|
<<: *build
|
||||||
tags:
|
image: dock.mau.dev/tulir/gomuks-build-docker:linux-amd64
|
||||||
- amd64
|
|
||||||
|
|
||||||
build arm64:
|
build arm64:
|
||||||
<<: *build
|
<<: *build
|
||||||
tags:
|
image: dock.mau.dev/tulir/gomuks-build-docker:linux-arm64
|
||||||
- arm64
|
|
||||||
|
build arm:
|
||||||
|
<<: *build
|
||||||
|
image: dock.mau.dev/tulir/gomuks-build-docker:linux-arm
|
||||||
|
|
||||||
build docker amd64:
|
build docker amd64:
|
||||||
<<: *build-docker
|
<<: *build-docker
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
FROM alpine:3.12
|
FROM alpine:3.12
|
||||||
|
|
||||||
ARG TARGETARCH=amd64
|
RUN echo $'\
|
||||||
ARG YQ_DOWNLOAD_ADDR=https://github.com/mikefarah/yq/releases/download/3.3.2/yq_linux_${TARGETARCH}
|
@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 \
|
ENV UID=1337 \
|
||||||
GID=1337
|
GID=1337
|
||||||
|
|
||||||
RUN apk add --no-cache ffmpeg su-exec ca-certificates olm bash jq curl && \
|
RUN apk add --no-cache ffmpeg su-exec ca-certificates bash jq curl yq@edge
|
||||||
curl -sLo yq ${YQ_DOWNLOAD_ADDR} && \
|
|
||||||
chmod +x yq && mv yq /usr/bin/yq
|
|
||||||
|
|
||||||
ARG EXECUTABLE=./mautrix-whatsapp
|
ARG EXECUTABLE=./mautrix-whatsapp
|
||||||
COPY $EXECUTABLE /usr/bin/mautrix-whatsapp
|
COPY $EXECUTABLE /usr/bin/mautrix-whatsapp
|
||||||
|
Loading…
Reference in New Issue
Block a user