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

Merged
Merged
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
17 changes: 13 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ RUN if [ "$TOMCAT_EXTRAS" = false ]; then \
find "${CATALINA_BASE}/webapps/" -delete; \
fi

# Create a non-privileged tomcat user
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 tomcat:tomcat ${CATALINA_BASE}/ && \
chown tomcat:tomcat /docker-entrypoint.d

# Add application from first stage
COPY --from=extractwar /tmp/mapstore "${CATALINA_BASE}/webapps/mapstore"
COPY georchestra-docker-scripts/ /
COPY --chown=tomcat:tomcat --from=extractwar /tmp/mapstore "${CATALINA_BASE}/webapps/mapstore"
COPY --chown=tomcat:tomcat georchestra-docker-scripts/ /
# SHould be override in 2024.xx when a server.xml on 8080 will be available
COPY docker/server.xml "${CATALINA_BASE}/conf/"

COPY --chown=tomcat:tomcat docker/server.xml "${CATALINA_BASE}/conf/"
USER tomcat

# Geostore externalization template. Disabled by default
# COPY docker/geostore-datasource-ovr.properties "${CATALINA_BASE}/conf/"
Expand All @@ -38,4 +46,5 @@ ENV TERM xterm
# Necessary to execute tomcat and custom scripts
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["catalina.sh", "run"]

jeanmi151 marked this conversation as resolved.
Show resolved Hide resolved
EXPOSE 8080
Loading