diff --git a/Dockerfile.ci b/Dockerfile.ci new file mode 100644 index 0000000..88bd04a --- /dev/null +++ b/Dockerfile.ci @@ -0,0 +1,14 @@ +FROM alpine:3.19 + +ENV UID=1337 \ + GID=1337 + +RUN apk add --no-cache ffmpeg su-exec ca-certificates bash jq curl yq + +ARG EXECUTABLE=./mautrix-imessage +COPY $EXECUTABLE /usr/bin/mautrix-imessage +COPY ./example-config.yaml /opt/mautrix-imessage/example-config.yaml +COPY ./docker-run.sh /docker-run.sh +VOLUME /data + +CMD ["/docker-run.sh"] diff --git a/docker-run.sh b/docker-run.sh new file mode 100755 index 0000000..da0b7b7 --- /dev/null +++ b/docker-run.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +if [[ -z "$GID" ]]; then + GID="$UID" +fi + +# Define functions. +function fixperms { + chown -R $UID:$GID /data + + # /opt/mautrix-imessage is read-only, so disable file logging if it's pointing there. + if [[ "$(yq e '.logging.writers[1].filename' /data/config.yaml)" == "./logs/mautrix-imessage.log" ]]; then + yq -I4 e -i 'del(.logging.writers[1])' /data/config.yaml + fi +} + +if [[ ! -f /data/config.yaml ]]; then + cp /opt/mautrix-imessage/example-config.yaml /data/config.yaml + echo "Didn't find a config file." + echo "Copied default config file to /data/config.yaml" + echo "Modify that config file to your liking." + echo "Start the container again after that to generate the registration file." + exit +fi + +if [[ ! -f /data/registration.yaml ]]; then + /usr/bin/mautrix-imessage -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." + exit +fi + +cd /data +fixperms +exec su-exec $UID:$GID /usr/bin/mautrix-imessage