From 5c55f677d58c61c5bfb3aa364207943d76b0e477 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 13 Jun 2024 16:02:38 +0300 Subject: [PATCH] ci: add separate dockerfile for v2 --- Dockerfile.v2.ci | 15 +++++++++++++++ docker-run.sh | 18 +++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 Dockerfile.v2.ci 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