Skip to content

Commit

Permalink
Fix #2680 - Run processes in Docker as non-root user (#3159)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wonderfall authored and Gargron committed May 20, 2017
1 parent 2c405ae commit d972845
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ FROM ruby:2.4.1-alpine
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

Expand All @@ -31,6 +31,8 @@ RUN echo "@edge https://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/reposit
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/*
Expand All @@ -42,4 +44,10 @@ RUN bundle install --deployment --without test development \

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"]
4 changes: 4 additions & 0 deletions docker_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/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 -- "$@"

0 comments on commit d972845

Please sign in to comment.