Skip to content

Commit

Permalink
Run tomcat as non-root user
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanpommier committed Mar 28, 2023
1 parent 98f4749 commit bb9cf90
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ RUN if [ "$TOMCAT_EXTRAS" = false ]; then \
find "${CATALINA_BASE}/webapps/" -delete; \
fi

# Create a non-privileged tomcat user
RUN addgroup --gid 999 tomcat && \
adduser --system -u 999 --gid 999 --no-create-home tomcat && \
chown -R 999:999 /usr/local/tomcat

# Add war files to be deployed
COPY docker/*.war "${CATALINA_BASE}/webapps/mapstore.war"
COPY --chown=999:999 docker/*.war "${CATALINA_BASE}/webapps/mapstore.war"

# Geostore externalization template. Disabled by default
# COPY docker/geostore-datasource-ovr.properties "${CATALINA_BASE}/conf/"
Expand All @@ -23,4 +28,6 @@ ENV JAVA_OPTS="${JAVA_OPTS} ${GEORCHESTRA_DATADIR_OPT}"
# Set variable to better handle terminal commands
ENV TERM xterm

USER tomcat

EXPOSE 8080

0 comments on commit bb9cf90

Please sign in to comment.