Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Docker permissions during the build process #6496

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ FROM ruby:2.5.0-alpine3.7
LABEL maintainer="https://github.com/tootsuite/mastodon" \
description="A GNU Social-compatible microblogging server"

ENV UID=991 GID=991 \
RAILS_SERVE_STATIC_FILES=true \
ARG UID=991
ARG GID=991

ENV RAILS_SERVE_STATIC_FILES=true \
RAILS_ENV=production NODE_ENV=production

ARG YARN_VERSION=1.3.2
Expand Down Expand Up @@ -70,10 +72,11 @@ RUN bundle config build.nokogiri --with-iconv-lib=/usr/local/lib --with-iconv-in

COPY . /mastodon
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can now run chown while copying, which is more efficient and saves you an additional run statement. I'd get rid of the chown statement in line 76 in favor of using COPY --chown=${UID}:${GID}?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could give it a try, indeed.


COPY docker_entrypoint.sh /usr/local/bin/run

RUN chmod +x /usr/local/bin/run
RUN addgroup -g ${GID} mastodon && adduser -h /mastodon -s /bin/sh -D -G mastodon -u ${UID} mastodon \
&& chown -R $UID:$GID /mastodon

VOLUME /mastodon/public/system /mastodon/public/assets /mastodon/public/packs

ENTRYPOINT ["/usr/local/bin/run"]
USER mastodon

ENTRYPOINT ["/sbin/tini", "--"]