From 84999d499385ec84254f466ae1a30f7e331be68b Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 13 Jun 2024 17:27:19 +0300 Subject: [PATCH] ci: build binaries and docker images for v2 (#518) --- .gitlab-ci.yml | 7 ++++++- Dockerfile.v2.ci | 15 +++++++++++++++ docker-run.sh | 18 +++++++++++++----- 3 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 Dockerfile.v2.ci diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6c694ebb..03bd8f54 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,12 +1,17 @@ include: - project: 'mautrix/ci' file: '/go.yml' +- project: 'mautrix/ci' + file: '/gov2.yml' variables: BUILDER_IMAGE: dock.mau.dev/tulir/gomuks-build-docker/signal - BINARY_NAME: mautrix-signal # 32-bit arm builds aren't supported build arm: rules: - when: never + +build arm v2: + rules: + - when: never diff --git a/Dockerfile.v2.ci b/Dockerfile.v2.ci new file mode 100644 index 00000000..d5868a75 --- /dev/null +++ b/Dockerfile.v2.ci @@ -0,0 +1,15 @@ +FROM alpine:3.20 + +ENV UID=1337 \ + GID=1337 + +RUN apk add --no-cache ffmpeg su-exec ca-certificates bash jq curl yq-go + +ARG EXECUTABLE=./mautrix-signal-v2 +COPY $EXECUTABLE /usr/bin/mautrix-signal-v2 +COPY ./docker-run.sh /docker-run.sh +ENV BRIDGEV2=1 +VOLUME /data +WORKDIR /data + +CMD ["/docker-run.sh"] diff --git a/docker-run.sh b/docker-run.sh index c760f6bc..6d6f3a70 100755 --- a/docker-run.sh +++ b/docker-run.sh @@ -4,6 +4,11 @@ if [[ -z "$GID" ]]; then GID="$UID" fi +BINARY_NAME=/usr/bin/mautrix-signal +if [[ "$BRIDGEV2" == "1" ]]; then + BINARY_NAME=/usr/bin/mautrix-signal-v2 +fi + # Define functions. function fixperms { chown -R $UID:$GID /data @@ -15,7 +20,11 @@ function fixperms { } if [[ ! -f /data/config.yaml ]]; then - cp /opt/mautrix-signal/example-config.yaml /data/config.yaml + if [[ "$BRIDGEV2" == "1" ]]; then + $BINARY_NAME -c /data/config -e + else + cp /opt/mautrix-signal/example-config.yaml /data/config.yaml + fi echo "Didn't find a config file." echo "Copied default config file to /data/config.yaml" echo "Modify that config file to your liking." @@ -24,7 +33,7 @@ if [[ ! -f /data/config.yaml ]]; then fi if [[ ! -f /data/registration.yaml ]]; then - /usr/bin/mautrix-signal -g -c /data/config.yaml -r /data/registration.yaml || exit $? + $BINARY_NAME -g -c /data/config.yaml -r /data/registration.yaml || exit $? echo "Didn't find a registration file." echo "Generated one for you." echo "See https://docs.mau.fi/bridges/general/registering-appservices.html on how to use it." @@ -34,13 +43,12 @@ fi cd /data fixperms -EXE=/usr/bin/mautrix-signal DLV=/usr/bin/dlv if [ -x "$DLV" ]; then if [ "$DBGWAIT" != 1 ]; then NOWAIT=1 fi - EXE="${DLV} exec ${EXE} ${NOWAIT:+--continue --accept-multiclient} --api-version 2 --headless -l :4040" + BINARY_NAME="${DLV} exec ${BINARY_NAME} ${NOWAIT:+--continue --accept-multiclient} --api-version 2 --headless -l :4040" fi -exec su-exec $UID:$GID $EXE +exec su-exec $UID:$GID $BINARY_NAME