mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
Makes docker images default to non-root execution (#1031)
De-escalates to a normal user when the docker image is run as root. Allows GRIST_DOCKER_USER and GRIST_DOCKER_GROUP to be passed to override the default de-escalation behaviour. Backwards compatible with previous root installations. -------- This change adds a new docker_entrypoint.sh, which when run as root de-escalates to the provided user, defaulting to grist:grist. This is similar to the approach used by the official postgres docker image. To achieve backwards compatibility, it changes ownership of any files in `/persist` to the user it's given at runtime. Since the docker container is typically run as root, this should always work. If the container is run as a standard user from the very start: * It's the admin's responsibility to ensure `/persist` is writable by that user. * `/grist` remains owned by root and is read-only.
This commit is contained in:
11
Dockerfile
11
Dockerfile
@@ -122,6 +122,15 @@ RUN \
|
||||
mv /grist/static-built/* /grist/static && \
|
||||
rmdir /grist/static-built
|
||||
|
||||
# To ensure non-root users can run grist, 'other' users need read access (and execute on directories)
|
||||
# This should be the case by default when copying files in.
|
||||
# Only uncomment this if running into permissions issues, as it takes a long time to execute on some systems.
|
||||
# RUN chmod -R o+rX /grist
|
||||
|
||||
# Add a user to allow de-escalating from root on startup
|
||||
RUN useradd -ms /bin/bash grist
|
||||
ENV GRIST_DOCKER_USER=grist \
|
||||
GRIST_DOCKER_GROUP=grist
|
||||
WORKDIR /grist
|
||||
|
||||
# Set some default environment variables to give a setup that works out of the box when
|
||||
@@ -151,5 +160,5 @@ ENV \
|
||||
|
||||
EXPOSE 8484
|
||||
|
||||
ENTRYPOINT ["/usr/bin/tini", "-s", "--"]
|
||||
ENTRYPOINT ["./sandbox/docker_entrypoint.sh"]
|
||||
CMD ["node", "./sandbox/supervisor.mjs"]
|
||||
|
||||
Reference in New Issue
Block a user