From 62049fdf82e38eeef963a5519b03126fae94d65a Mon Sep 17 00:00:00 2001 From: Hugues Morisset Date: Wed, 24 Oct 2018 15:46:15 +0200 Subject: [PATCH] Allow to set uid guid when running whatsapp program Set it using the env variable UID and GUID --- Dockerfile | 6 ++++++ docker-run.sh | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d345c05..aebc0fe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,12 @@ RUN go build -o /usr/bin/mautrix-whatsapp FROM alpine:latest +ENV UID=1337 \ + GID=1337 + +RUN apk add --no-cache \ + su-exec + COPY --from=builder /usr/bin/mautrix-whatsapp /usr/bin/mautrix-whatsapp COPY --from=builder /etc/ssl/certs/ /etc/ssl/certs COPY --from=builder /go/src/maunium.net/go/mautrix-whatsapp/example-config.yaml /opt/mautrix-whatsapp/example-config.yaml diff --git a/docker-run.sh b/docker-run.sh index 982aa57..67d40a9 100755 --- a/docker-run.sh +++ b/docker-run.sh @@ -1,5 +1,10 @@ #!/bin/sh +# Define functions. +function fixperms { + chown -R $UID:$GID /data /opt/mautrix-whatsapp +} + if [ ! -f /data/config.yaml ]; then cp /opt/mautrix-whatsapp/example-config.yaml /data/config.yaml echo "Didn't find a config file." @@ -18,4 +23,5 @@ if [ ! -f /data/registration.yaml ]; then fi cd /data -/usr/bin/mautrix-whatsapp +fixperms +exec su-exec $UID:$GID /usr/bin/mautrix-whatsapp