LABEL maintainer="https://github.com/tootsuite/mastodon" \
description="A GNU Social-compatible microblogging server"
-ENV RAILS_ENV=production \
- NODE_ENV=production
+ENV UID=991 GID=991 \
+ RAILS_ENV=production NODE_ENV=production
EXPOSE 3000 4000
imagemagick@edge \
ca-certificates \
protobuf \
+ tini \
+ su-exec \
&& npm install -g npm@3 && npm install -g yarn \
&& update-ca-certificates \
&& rm -rf /tmp/* /var/cache/apk/*
COPY . /mastodon
+COPY docker_entrypoint.sh /usr/local/bin/run
+
+RUN chmod +x /usr/local/bin/run
+
VOLUME /mastodon/public/system /mastodon/public/assets /mastodon/public/packs
+
+ENTRYPOINT ["/usr/local/bin/run"]
--- /dev/null
+#!/bin/sh
+addgroup -g ${GID} mastodon && adduser -h /mastodon -s /bin/sh -D -G mastodon -u ${UID} mastodon
+find /mastodon -path /mastodon/public/system -prune -o -not -user mastodon -not -group mastodon -print0 | xargs -0 chown -f mastodon:mastodon
+su-exec mastodon:mastodon /sbin/tini -- "$@"