mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Merge pull request #10135 from DSpace/backport-10132-to-dspace-8_x
[Port dspace-8_x] [Docker] Minor Dockerfile enhancements to stabilize & speed up automated builds
This commit is contained in:
10
Dockerfile
10
Dockerfile
@@ -44,14 +44,12 @@ WORKDIR /dspace-src
|
||||
ENV ANT_VERSION=1.10.13
|
||||
ENV ANT_HOME=/tmp/ant-$ANT_VERSION
|
||||
ENV PATH=$ANT_HOME/bin:$PATH
|
||||
# Need wget to install ant
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends wget \
|
||||
&& apt-get purge -y --auto-remove \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
# Download and install 'ant'
|
||||
RUN mkdir $ANT_HOME && \
|
||||
wget -qO- "https://archive.apache.org/dist/ant/binaries/apache-ant-$ANT_VERSION-bin.tar.gz" | tar -zx --strip-components=1 -C $ANT_HOME
|
||||
curl --silent --show-error --location --fail --retry 5 --output /tmp/apache-ant.tar.gz \
|
||||
https://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz && \
|
||||
tar -zx --strip-components=1 -f /tmp/apache-ant.tar.gz -C $ANT_HOME && \
|
||||
rm /tmp/apache-ant.tar.gz
|
||||
# Run necessary 'ant' deploy scripts
|
||||
RUN ant init_installation update_configs update_code update_webapps
|
||||
|
||||
|
@@ -38,14 +38,12 @@ WORKDIR /dspace-src
|
||||
ENV ANT_VERSION=1.10.13
|
||||
ENV ANT_HOME=/tmp/ant-$ANT_VERSION
|
||||
ENV PATH=$ANT_HOME/bin:$PATH
|
||||
# Need wget to install ant
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends wget \
|
||||
&& apt-get purge -y --auto-remove \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
# Download and install 'ant'
|
||||
RUN mkdir $ANT_HOME && \
|
||||
wget -qO- "https://archive.apache.org/dist/ant/binaries/apache-ant-$ANT_VERSION-bin.tar.gz" | tar -zx --strip-components=1 -C $ANT_HOME
|
||||
curl --silent --show-error --location --fail --retry 5 --output /tmp/apache-ant.tar.gz \
|
||||
https://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz && \
|
||||
tar -zx --strip-components=1 -f /tmp/apache-ant.tar.gz -C $ANT_HOME && \
|
||||
rm /tmp/apache-ant.tar.gz
|
||||
# Run necessary 'ant' deploy scripts
|
||||
RUN ant init_installation update_configs update_code
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# To build with other versions, use "--build-arg JDK_VERSION=[value]"
|
||||
ARG JDK_VERSION=17
|
||||
|
||||
# Step 1 - Run Maven Build
|
||||
# Step 1 - Download all Dependencies
|
||||
FROM docker.io/maven:3-eclipse-temurin-${JDK_VERSION} AS build
|
||||
ARG TARGET_DIR=dspace-installer
|
||||
WORKDIR /app
|
||||
@@ -19,16 +19,60 @@ RUN chown -Rv dspace: /app
|
||||
# Switch to dspace user & run below commands as that user
|
||||
USER dspace
|
||||
|
||||
# Copy the DSpace source code (from local machine) into the workdir (excluding .dockerignore contents)
|
||||
ADD --chown=dspace . /app/
|
||||
# This next part may look odd, but it speeds up the build of this image *significantly*.
|
||||
# Copy ONLY the POMs to this image (from local machine). This will allow us to download all dependencies *without*
|
||||
# performing any code compilation steps.
|
||||
|
||||
# Parent POM
|
||||
ADD --chown=dspace pom.xml /app/
|
||||
RUN mkdir -p /app/dspace
|
||||
|
||||
# 'dspace' module POM. Includes 'additions' ONLY, as it's the only submodule that is required to exist.
|
||||
ADD --chown=dspace dspace/pom.xml /app/dspace/
|
||||
RUN mkdir -p /app/dspace/modules/
|
||||
ADD --chown=dspace dspace/modules/pom.xml /app/dspace/modules/
|
||||
RUN mkdir -p /app/dspace/modules/additions
|
||||
ADD --chown=dspace dspace/modules/additions/pom.xml /app/dspace/modules/additions/
|
||||
|
||||
# 'dspace-api' module POM
|
||||
RUN mkdir -p /app/dspace-api
|
||||
ADD --chown=dspace dspace-api/pom.xml /app/dspace-api/
|
||||
|
||||
# 'dspace-iiif' module POM
|
||||
RUN mkdir -p /app/dspace-iiif
|
||||
ADD --chown=dspace dspace-iiif/pom.xml /app/dspace-iiif/
|
||||
|
||||
# 'dspace-oai' module POM
|
||||
RUN mkdir -p /app/dspace-oai
|
||||
ADD --chown=dspace dspace-oai/pom.xml /app/dspace-oai/
|
||||
|
||||
# 'dspace-rdf' module POM
|
||||
RUN mkdir -p /app/dspace-rdf
|
||||
ADD --chown=dspace dspace-rdf/pom.xml /app/dspace-rdf/
|
||||
|
||||
# 'dspace-server-webapp' module POM
|
||||
RUN mkdir -p /app/dspace-server-webapp
|
||||
ADD --chown=dspace dspace-server-webapp/pom.xml /app/dspace-server-webapp/
|
||||
|
||||
# 'dspace-services' module POM
|
||||
RUN mkdir -p /app/dspace-services
|
||||
ADD --chown=dspace dspace-services/pom.xml /app/dspace-services/
|
||||
|
||||
# 'dspace-sword' module POM
|
||||
RUN mkdir -p /app/dspace-sword
|
||||
ADD --chown=dspace dspace-sword/pom.xml /app/dspace-sword/
|
||||
|
||||
# 'dspace-swordv2' module POM
|
||||
RUN mkdir -p /app/dspace-swordv2
|
||||
ADD --chown=dspace dspace-swordv2/pom.xml /app/dspace-swordv2/
|
||||
|
||||
# Trigger the installation of all maven dependencies (hide download progress messages)
|
||||
# Maven flags here ensure that we skip final assembly, skip building test environment and skip all code verification checks.
|
||||
# These flags speed up this installation as much as reasonably possible.
|
||||
ENV MAVEN_FLAGS="-P-assembly -P-test-environment -Denforcer.skip=true -Dcheckstyle.skip=true -Dlicense.skip=true -Dxml.skip=true"
|
||||
RUN mvn --no-transfer-progress install ${MAVEN_FLAGS}
|
||||
# These flags speed up this installation and skip tasks we cannot perform as we don't have the full source code.
|
||||
ENV MAVEN_FLAGS="-P-assembly -P-test-environment -Denforcer.skip=true -Dcheckstyle.skip=true -Dlicense.skip=true -Dxjc.skip=true -Dxml.skip=true"
|
||||
RUN mvn --no-transfer-progress verify ${MAVEN_FLAGS}
|
||||
|
||||
# Clear the contents of the /app directory (including all maven builds), so no artifacts remain.
|
||||
# Clear the contents of the /app directory (including all maven target folders), so no artifacts remain.
|
||||
# This ensures when dspace:dspace is built, it will use the Maven local cache (~/.m2) for dependencies
|
||||
USER root
|
||||
RUN rm -rf /app/*
|
||||
|
@@ -43,14 +43,12 @@ WORKDIR /dspace-src
|
||||
ENV ANT_VERSION=1.10.12
|
||||
ENV ANT_HOME=/tmp/ant-$ANT_VERSION
|
||||
ENV PATH=$ANT_HOME/bin:$PATH
|
||||
# Need wget to install ant
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends wget \
|
||||
&& apt-get purge -y --auto-remove \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
# Download and install 'ant'
|
||||
RUN mkdir $ANT_HOME && \
|
||||
wget -qO- "https://archive.apache.org/dist/ant/binaries/apache-ant-$ANT_VERSION-bin.tar.gz" | tar -zx --strip-components=1 -C $ANT_HOME
|
||||
curl --silent --show-error --location --fail --retry 5 --output /tmp/apache-ant.tar.gz \
|
||||
https://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz && \
|
||||
tar -zx --strip-components=1 -f /tmp/apache-ant.tar.gz -C $ANT_HOME && \
|
||||
rm /tmp/apache-ant.tar.gz
|
||||
# Run necessary 'ant' deploy scripts
|
||||
RUN ant init_installation update_configs update_code update_webapps
|
||||
|
||||
|
Reference in New Issue
Block a user