88ARG JDK_VERSION=11
99
1010# Step 1 - Run Maven Build
11- FROM ufal/dspace-dependencies:dspace-7_x as build
11+ FROM ufal/dspace-dependencies:dspace-7_x AS build
1212ARG TARGET_DIR=dspace-installer
1313WORKDIR /app
1414# The dspace-installer directory will be written to /install
1515RUN mkdir /install \
1616 && chown -Rv dspace: /install \
1717 && chown -Rv dspace: /app
18- USER dspace
18+ USER 10001
1919# Copy the DSpace source code (from local machine) into the workdir (excluding .dockerignore contents)
2020ADD --chown=dspace . /app/
2121# Build DSpace (note: this build doesn't include the optional, deprecated "dspace-rest" webapp)
@@ -25,7 +25,7 @@ RUN mvn --no-transfer-progress package && \
2525 mvn clean
2626
2727# Step 2 - Run Ant Deploy
28- FROM openjdk:${JDK_VERSION}-slim as ant_build
28+ FROM openjdk:${JDK_VERSION}-slim AS ant_build
2929ARG TARGET_DIR=dspace-installer
3030# COPY the /install directory from 'build' container to /dspace-src in this container
3131COPY --from=build /install /dspace-src
@@ -48,16 +48,19 @@ RUN ant init_installation update_configs update_code update_webapps
4848# Step 3 - Run tomcat
4949# Create a new tomcat image that does not retain the the build directory contents
5050FROM tomcat:9-jdk${JDK_VERSION}
51+ # Create a custom dspace user matching previous in last stage
52+ RUN groupadd -g 10002 dspace && \
53+ useradd -u 10001 -g dspace dspace
5154# NOTE: DSPACE_INSTALL must align with the "dspace.dir" default configuration.
5255ENV DSPACE_INSTALL=/dspace
5356# Copy the /dspace directory from 'ant_build' container to /dspace in this container
54- COPY --from=ant_build /dspace $DSPACE_INSTALL
57+ COPY --from=ant_build --chown=10001:10002 /dspace $DSPACE_INSTALL
5558# Expose Tomcat port and AJP port
5659EXPOSE 8080 8009 8000
5760# Give java extra memory (2GB)
5861ENV JAVA_OPTS=-Xmx2000m
59- COPY scripts/restart_debug/* /usr/local/tomcat/bin
60- COPY scripts/index-scripts/* /dspace/bin
62+ COPY --chown=10001:10002 scripts/restart_debug/* /usr/local/tomcat/bin
63+ COPY --chown=10001:10002 scripts/index-scripts/* /dspace/bin
6164# Link the DSpace 'server' webapp into Tomcat's webapps directory.
6265# This ensures that when we start Tomcat, it runs from /server path (e.g. http://localhost:8080/server/)
6366RUN ln -s $DSPACE_INSTALL/webapps/server /usr/local/tomcat/webapps/server
@@ -66,6 +69,8 @@ RUN ln -s $DSPACE_INSTALL/webapps/server /usr/local/tomcat/webapps/server
6669# Please note that server webapp should only run on one path at a time.
6770# RUN mv /usr/local/tomcat/webapps/ROOT /usr/local/tomcat/webapps/ROOT.bk && \
6871# ln -s $DSPACE_INSTALL/webapps/server /usr/local/tomcat/webapps/ROOT
72+ # Run as dspace user
73+ USER 10001
6974
7075WORKDIR /usr/local/tomcat/bin
7176RUN chmod u+x redebug.sh undebug.sh custom_run.sh
0 commit comments