diff --git a/Dockerfile b/Dockerfile index de6c00ce72..964b76a256 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,8 @@ ENV MAVEN_FLAGS="-P-test-environment -Denforcer.skip=true -Dcheckstyle.skip=true RUN mvn --no-transfer-progress package ${MAVEN_FLAGS} && \ mv /app/dspace/target/${TARGET_DIR}/* /install && \ mvn clean +# Remove the server webapp to keep image small. +RUN rm -rf /install/webapps/server/ # Step 2 - Run Ant Deploy FROM eclipse-temurin:${JDK_VERSION} as ant_build @@ -49,23 +51,16 @@ RUN mkdir $ANT_HOME && \ # Run necessary 'ant' deploy scripts RUN ant init_installation update_configs update_code update_webapps -# Step 3 - Run tomcat -# Create a new tomcat image that does not retain the the build directory contents -FROM tomcat:10-jdk${JDK_VERSION} +# Step 3 - Start up DSpace via Runnable JAR +FROM eclipse-temurin:${JDK_VERSION} # NOTE: DSPACE_INSTALL must align with the "dspace.dir" default configuration. ENV DSPACE_INSTALL=/dspace # Copy the /dspace directory from 'ant_build' container to /dspace in this container COPY --from=ant_build /dspace $DSPACE_INSTALL -# Expose Tomcat port and AJP port -EXPOSE 8080 8009 +WORKDIR $DSPACE_INSTALL +# Expose Tomcat port +EXPOSE 8080 # Give java extra memory (2GB) ENV JAVA_OPTS=-Xmx2000m - -# Link the DSpace 'server' webapp into Tomcat's webapps directory. -# This ensures that when we start Tomcat, it runs from /server path (e.g. http://localhost:8080/server/) -RUN ln -s $DSPACE_INSTALL/webapps/server /usr/local/tomcat/webapps/server -# If you wish to run "server" webapp off the ROOT path, then comment out the above RUN, and uncomment the below RUN. -# You also MUST update the 'dspace.server.url' configuration to match. -# Please note that server webapp should only run on one path at a time. -#RUN mv /usr/local/tomcat/webapps/ROOT /usr/local/tomcat/webapps/ROOT.bk && \ -# ln -s $DSPACE_INSTALL/webapps/server /usr/local/tomcat/webapps/ROOT +# On startup, run DSpace Runnable JAR +ENTRYPOINT ["java", "-jar", "webapps/server-boot.jar", "--dspace.dir=$DSPACE_INSTALL"] diff --git a/Dockerfile.test b/Dockerfile.test index 9f59c34722..cdfd5e83af 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -26,6 +26,8 @@ ADD --chown=dspace . /app/ RUN mvn --no-transfer-progress package && \ mv /app/dspace/target/${TARGET_DIR}/* /install && \ mvn clean +# Remove the server webapp to keep image small. Rename runnable JAR to server-boot.jar. +RUN rm -rf /install/webapps/server/ # Step 2 - Run Ant Deploy FROM eclipse-temurin:${JDK_VERSION} as ant_build @@ -48,29 +50,18 @@ RUN mkdir $ANT_HOME && \ # Run necessary 'ant' deploy scripts RUN ant init_installation update_configs update_code update_webapps -# Step 3 - Run tomcat -# Create a new tomcat image that does not retain the the build directory contents -FROM tomcat:10-jdk${JDK_VERSION} +# Step 3 - Start up DSpace via Runnable JAR +FROM eclipse-temurin:${JDK_VERSION} +# NOTE: DSPACE_INSTALL must align with the "dspace.dir" default configuration. ENV DSPACE_INSTALL=/dspace -ENV TOMCAT_INSTALL=/usr/local/tomcat -# Copy the /dspace directory from 'ant_build' containger to /dspace in this container +# Copy the /dspace directory from 'ant_build' container to /dspace in this container COPY --from=ant_build /dspace $DSPACE_INSTALL -# Enable the AJP connector in Tomcat's server.xml -# NOTE: secretRequired="false" should only be used when AJP is NOT accessible from an external network. But, secretRequired="true" isn't supported by mod_proxy_ajp until Apache 2.5 -RUN sed -i '/Service name="Catalina".*/a \\n ' $TOMCAT_INSTALL/conf/server.xml -# Expose Tomcat port and AJP port -EXPOSE 8080 8009 8000 +WORKDIR $DSPACE_INSTALL +# Expose Tomcat port and debugging port +EXPOSE 8080 8000 # Give java extra memory (2GB) ENV JAVA_OPTS=-Xmx2000m # Set up debugging ENV CATALINA_OPTS=-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=*:8000 - -# Link the DSpace 'server' webapp into Tomcat's webapps directory. -# This ensures that when we start Tomcat, it runs from /server path (e.g. http://localhost:8080/server/) -RUN ln -s $DSPACE_INSTALL/webapps/server /usr/local/tomcat/webapps/server -# If you wish to run "server" webapp off the ROOT path, then comment out the above RUN, and uncomment the below RUN. -# You also MUST update the 'dspace.server.url' configuration to match. -# Please note that server webapp should only run on one path at a time. -#RUN mv /usr/local/tomcat/webapps/ROOT /usr/local/tomcat/webapps/ROOT.bk && \ -# ln -s $DSPACE_INSTALL/webapps/server /usr/local/tomcat/webapps/ROOT - +# On startup, run DSpace Runnable JAR +ENTRYPOINT ["java", "-jar", "webapps/server-boot.jar", "--dspace.dir=$DSPACE_INSTALL"] diff --git a/docker-compose.yml b/docker-compose.yml index 82dc70f71f..6a930a8d31 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -39,8 +39,6 @@ services: ports: - published: 8080 target: 8080 - - published: 8009 - target: 8009 - published: 8000 target: 8000 stdin_open: true @@ -54,14 +52,14 @@ services: # Ensure that the database is ready BEFORE starting tomcat # 1. While a TCP connection to dspacedb port 5432 is not available, continue to sleep # 2. Then, run database migration to init database tables - # 3. Finally, start Tomcat + # 3. Finally, start DSpace entrypoint: - /bin/bash - '-c' - | while (! /dev/null 2>&1; do sleep 1; done; /dspace/bin/dspace database migrate - catalina.sh run + java -jar /dspace/webapps/server-boot.jar --dspace.dir=/dspace # DSpace PostgreSQL database container dspacedb: container_name: dspacedb diff --git a/dspace/src/main/assembly/assembly.xml b/dspace/src/main/assembly/assembly.xml index 97cfac8ed3..420eb46314 100644 --- a/dspace/src/main/assembly/assembly.xml +++ b/dspace/src/main/assembly/assembly.xml @@ -62,10 +62,6 @@ bin bin - - etc - etc - solr solr @@ -95,7 +91,7 @@ org.dspace.modules:*:jar:* - + true lib false @@ -110,6 +106,21 @@ + + + + org.dspace:server-boot + + + false + webapps + false + ${artifact.artifactId}.${artifact.extension} + + + - - org.antlr - antlr4-runtime - - @@ -1126,6 +1119,13 @@ 3.4.3.Final + + + org.antlr + antlr4-runtime + 4.13.1 + + com.rometools