mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-19 16:03:07 +00:00
Optimize docker builds
This commit is contained in:
25
Dockerfile.dependencies
Normal file
25
Dockerfile.dependencies
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# This image will be published as dspace/dspace-dependencies
|
||||||
|
# The purpose of this image is to make the build for dspace/dspace run faster
|
||||||
|
|
||||||
|
# Step 1 - Run Maven Build
|
||||||
|
FROM maven as build
|
||||||
|
ARG TARGET_DIR=dspace-installer
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# The Mirage2 build cannot run as root. Setting the user to dspace.
|
||||||
|
RUN useradd dspace \
|
||||||
|
&& mkdir /home/dspace \
|
||||||
|
&& chown -Rv dspace: /home/dspace
|
||||||
|
USER dspace
|
||||||
|
|
||||||
|
# Copy the DSpace source code into the workdir (excluding .dockerignore contents)
|
||||||
|
ADD --chown=dspace . /app/
|
||||||
|
COPY dspace/src/main/docker/local.cfg /app/local.cfg
|
||||||
|
|
||||||
|
# Trigger the installation of all maven dependencies including the Mirage2 dependencies
|
||||||
|
# Clean up the built artifacts in the same step to keep the docker image small
|
||||||
|
RUN mvn package -Dmirage2.on=true && mvn clean
|
||||||
|
|
||||||
|
# clear the contents of the /app directory so no artifacts are left when dspace:dspace is built
|
||||||
|
USER root
|
||||||
|
RUN rm -rf /app/*
|
@@ -9,26 +9,30 @@
|
|||||||
# - default tag for branch: dspace/dspace: dspace/dspace:dspace-6_x-jdk8
|
# - default tag for branch: dspace/dspace: dspace/dspace:dspace-6_x-jdk8
|
||||||
|
|
||||||
# Step 1 - Run Maven Build
|
# Step 1 - Run Maven Build
|
||||||
FROM maven as build
|
FROM dspace/dspace-dependencies:dspace-6_x as build
|
||||||
|
ARG TARGET_DIR=dspace-installer
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# The Mirage2 build cannot run as root. Setting the user to dspace.
|
# The dspace-install directory will be written to /install
|
||||||
RUN useradd dspace \
|
RUN mkdir /install \
|
||||||
&& mkdir /home/dspace \
|
&& chown -Rv dspace: /install
|
||||||
&& chown -Rv dspace: /home/dspace
|
|
||||||
USER dspace
|
USER dspace
|
||||||
|
|
||||||
# Copy the DSpace source code into the workdir (excluding .dockerignore contents)
|
# Copy the DSpace source code into the workdir (excluding .dockerignore contents)
|
||||||
ADD --chown=dspace . /app/
|
ADD --chown=dspace . /app/
|
||||||
COPY dspace/src/main/docker/local.cfg /app/local.cfg
|
COPY dspace/src/main/docker/local.cfg /app/local.cfg
|
||||||
|
|
||||||
RUN mvn package -Dmirage2.on=true
|
# Build DSpace. Copy the dspace-install directory to /install. Clean up the build to keep the docker image small
|
||||||
|
RUN mvn package -Dmirage2.on=true && \
|
||||||
|
mv /app/dspace/target/${TARGET_DIR}/* /install && \
|
||||||
|
mvn clean
|
||||||
|
|
||||||
# Step 2 - Run Ant Deploy
|
# Step 2 - Run Ant Deploy
|
||||||
FROM tomcat:8-jre8 as ant_build
|
FROM tomcat:8-jre8 as ant_build
|
||||||
ARG TARGET_DIR=dspace-installer
|
ARG TARGET_DIR=dspace-installer
|
||||||
COPY --from=build /app /dspace-src
|
COPY --from=build /install /dspace-src
|
||||||
WORKDIR /dspace-src/dspace/target/${TARGET_DIR}
|
WORKDIR /dspace-src
|
||||||
|
|
||||||
# Create the initial install deployment using ANT
|
# Create the initial install deployment using ANT
|
||||||
ENV ANT_VERSION 1.10.5
|
ENV ANT_VERSION 1.10.5
|
||||||
|
@@ -9,13 +9,13 @@
|
|||||||
# - default tag for branch: dspace/dspace: dspace/dspace:dspace-6_x-jdk8
|
# - default tag for branch: dspace/dspace: dspace/dspace:dspace-6_x-jdk8
|
||||||
|
|
||||||
# Step 1 - Run Maven Build
|
# Step 1 - Run Maven Build
|
||||||
FROM maven as build
|
FROM dspace/dspace-dependencies:dspace-6_x as build
|
||||||
|
ARG TARGET_DIR=dspace-installer
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# The Mirage2 build cannot run as root. Setting the user to dspace.
|
RUN mkdir /install \
|
||||||
RUN useradd dspace \
|
&& chown -Rv dspace: /install
|
||||||
&& mkdir /home/dspace \
|
|
||||||
&& chown -Rv dspace: /home/dspace
|
|
||||||
USER dspace
|
USER dspace
|
||||||
|
|
||||||
# Copy the DSpace source code into the workdir (excluding .dockerignore contents)
|
# Copy the DSpace source code into the workdir (excluding .dockerignore contents)
|
||||||
@@ -26,13 +26,15 @@ COPY dspace/src/main/docker/local.cfg /app/local.cfg
|
|||||||
COPY dspace/src/main/docker/test/solr_web.xml /app/dspace-solr/src/main/webapp/WEB-INF/web.xml
|
COPY dspace/src/main/docker/test/solr_web.xml /app/dspace-solr/src/main/webapp/WEB-INF/web.xml
|
||||||
COPY dspace/src/main/docker/test/rest_web.xml /app/dspace-rest/src/main/webapp/WEB-INF/web.xml
|
COPY dspace/src/main/docker/test/rest_web.xml /app/dspace-rest/src/main/webapp/WEB-INF/web.xml
|
||||||
|
|
||||||
RUN mvn package -Dmirage2.on=true
|
RUN mvn package -Dmirage2.on=true && \
|
||||||
|
mv /app/dspace/target/${TARGET_DIR}/* /install && \
|
||||||
|
mvn clean
|
||||||
|
|
||||||
# Step 2 - Run Ant Deploy
|
# Step 2 - Run Ant Deploy
|
||||||
FROM tomcat:8-jre8 as ant_build
|
FROM tomcat:8-jre8 as ant_build
|
||||||
ARG TARGET_DIR=dspace-installer
|
ARG TARGET_DIR=dspace-installer
|
||||||
COPY --from=build /app /dspace-src
|
COPY --from=build /install /dspace-src
|
||||||
WORKDIR /dspace-src/dspace/target/${TARGET_DIR}
|
WORKDIR /dspace-src
|
||||||
|
|
||||||
# Create the initial install deployment using ANT
|
# Create the initial install deployment using ANT
|
||||||
ENV ANT_VERSION 1.10.5
|
ENV ANT_VERSION 1.10.5
|
||||||
|
Reference in New Issue
Block a user