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

Run tomcat as non-root user #612

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jeanpommier
Copy link
Member

update based on PR #442

@jeanpommier
Copy link
Member Author

@pierrejego I believe we can merge this PR.

We will need to document in the migration notes that the mapstore writable datadir needs to be writable by UID/GID 999 (for the docker version)

Copy link
Member

@edevosc2c edevosc2c left a comment

Choose a reason for hiding this comment

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

Could you allow changing the UID and GID at build time?

You can do it with something like this:

ARG USER_GID=999
ARG USER_UID=999
RUN addgroup --gid ${USER_GID} tomcat && \
    adduser --system  -u ${USER_UID} --gid ${USER_GID} --no-create-home tomcat && \
    chown -R ${USER_UID}:${USER_GID} /usr/local/tomcat

@jeanpommier
Copy link
Member Author

Hi @edevosc2c . Can you explain why for ?

The idea is to run the georchestra official docker image, right ? Since this applies at build time, it means that to get different settings one would still have a build a custom image. I don't see the added value

@pmauduit
Copy link
Member

Can you explain why for ?

it looks like because of georchestra/georchestra#4071

@edevosc2c
Copy link
Member

edevosc2c commented Nov 13, 2023

Hi @edevosc2c . Can you explain why for ?

The idea is to run the georchestra official docker image, right ? Since this applies at build time, it means that to get different settings one would still have a build a custom image. I don't see the added value

It's a standard thing in docker images to allow anyone to set UID and GID at build time.
It doesn't hurt to add it.

On top of that, you have just one line/one place to change the UID and GID in case it's needed.

@edevosc2c
Copy link
Member

edevosc2c commented Nov 29, 2023

Note: Once #671 will be merged, there will be a need here to add after RUN mkdir -p /docker-entrypoint.d this line:

RUN chown tomcat:tomcat /docker-entrypoint.d

Otherwise, the copy in this script won't work: https://github.com/georchestra/mapstore2-georchestra/pull/671/files#diff-1b0bf6d59703af25ba177c67baa3686a4aa1846098b91e7ff32375e0f4eb43eaR10

@jeanpommier
Copy link
Member Author

Hi,
Sorry I had left this PR untidy. I've updated the PR according to your suggestions @edevosc2c.
Does it look OK to you ?

Dockerfile Show resolved Hide resolved
Copy link
Member

@edevosc2c edevosc2c left a comment

Choose a reason for hiding this comment

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

good for merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants