Skip to content

Commit

Permalink
Add dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Jan 14, 2024
1 parent 83d355a commit 1dbae49
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -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"]
36 changes: 36 additions & 0 deletions docker-run.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1dbae49

Please sign in to comment.