Skip to content

Commit 541fc18

Browse files
authored
Merge pull request DSpace#11789 from MMilosz/chore/docker-resolve-dockerfile-lint-warnings
chore: resolve Dockerfile lint warnings
2 parents 0e977f6 + f9f1d50 commit 541fc18

File tree

7 files changed

+37
-24
lines changed

7 files changed

+37
-24
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ FROM ${DOCKER_REGISTRY}/dspace/dspace-dependencies:${DSPACE_VERSION} AS build
1717
ARG TARGET_DIR=dspace-installer
1818
WORKDIR /app
1919
# The dspace-installer directory will be written to /install
20+
USER root
2021
RUN mkdir /install \
2122
&& chown -Rv dspace: /install \
2223
&& chown -Rv dspace: /app
2324
USER dspace
2425
# Copy the DSpace source code (from local machine) into the workdir (excluding .dockerignore contents)
25-
ADD --chown=dspace . /app/
26+
COPY --chown=dspace . /app/
2627
# Build DSpace
2728
# Copy the dspace-installer directory to /install. Clean up the build to keep the docker image small
2829
# Maven flags here ensure that we skip building test environment and skip all code verification checks.

Dockerfile.cli

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ FROM ${DOCKER_REGISTRY}/dspace/dspace-dependencies:${DSPACE_VERSION} AS build
1717
ARG TARGET_DIR=dspace-installer
1818
WORKDIR /app
1919
# The dspace-installer directory will be written to /install
20+
USER root
2021
RUN mkdir /install \
2122
&& chown -Rv dspace: /install \
2223
&& chown -Rv dspace: /app
2324
USER dspace
2425
# Copy the DSpace source code (from local machine) into the workdir (excluding .dockerignore contents)
25-
ADD --chown=dspace . /app/
26+
COPY --chown=dspace . /app/
2627
# Build DSpace. Copy the dspace-installer directory to /install. Clean up the build to keep the docker image small
2728
RUN mvn --no-transfer-progress package && \
2829
mv /app/dspace/target/${TARGET_DIR}/* /install && \

Dockerfile.dependencies

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,51 +24,51 @@ USER dspace
2424
# performing any code compilation steps.
2525

2626
# Parent POM
27-
ADD --chown=dspace pom.xml /app/
27+
COPY --chown=dspace pom.xml /app/
2828
RUN mkdir -p /app/dspace
2929

3030
# 'dspace' module POM. Includes 'additions' ONLY, as it's the only submodule that is required to exist.
31-
ADD --chown=dspace dspace/pom.xml /app/dspace/
31+
COPY --chown=dspace dspace/pom.xml /app/dspace/
3232
RUN mkdir -p /app/dspace/modules/
33-
ADD --chown=dspace dspace/modules/pom.xml /app/dspace/modules/
33+
COPY --chown=dspace dspace/modules/pom.xml /app/dspace/modules/
3434
RUN mkdir -p /app/dspace/modules/additions
35-
ADD --chown=dspace dspace/modules/additions/pom.xml /app/dspace/modules/additions/
35+
COPY --chown=dspace dspace/modules/additions/pom.xml /app/dspace/modules/additions/
3636

3737
# 'dspace-api' module POM
3838
RUN mkdir -p /app/dspace-api
39-
ADD --chown=dspace dspace-api/pom.xml /app/dspace-api/
39+
COPY --chown=dspace dspace-api/pom.xml /app/dspace-api/
4040

4141
# 'dspace-iiif' module POM
4242
RUN mkdir -p /app/dspace-iiif
43-
ADD --chown=dspace dspace-iiif/pom.xml /app/dspace-iiif/
43+
COPY --chown=dspace dspace-iiif/pom.xml /app/dspace-iiif/
4444

4545
# 'dspace-oai' module POM
4646
RUN mkdir -p /app/dspace-oai
47-
ADD --chown=dspace dspace-oai/pom.xml /app/dspace-oai/
47+
COPY --chown=dspace dspace-oai/pom.xml /app/dspace-oai/
4848

4949
# 'dspace-rdf' module POM
5050
RUN mkdir -p /app/dspace-rdf
51-
ADD --chown=dspace dspace-rdf/pom.xml /app/dspace-rdf/
51+
COPY --chown=dspace dspace-rdf/pom.xml /app/dspace-rdf/
5252

5353
# 'dspace-saml2' module POM
5454
RUN mkdir -p /app/dspace-saml2
55-
ADD --chown=dspace dspace-saml2/pom.xml /app/dspace-saml2/
55+
COPY --chown=dspace dspace-saml2/pom.xml /app/dspace-saml2/
5656

5757
# 'dspace-server-webapp' module POM
5858
RUN mkdir -p /app/dspace-server-webapp
59-
ADD --chown=dspace dspace-server-webapp/pom.xml /app/dspace-server-webapp/
59+
COPY --chown=dspace dspace-server-webapp/pom.xml /app/dspace-server-webapp/
6060

6161
# 'dspace-services' module POM
6262
RUN mkdir -p /app/dspace-services
63-
ADD --chown=dspace dspace-services/pom.xml /app/dspace-services/
63+
COPY --chown=dspace dspace-services/pom.xml /app/dspace-services/
6464

6565
# 'dspace-sword' module POM
6666
RUN mkdir -p /app/dspace-sword
67-
ADD --chown=dspace dspace-sword/pom.xml /app/dspace-sword/
67+
COPY --chown=dspace dspace-sword/pom.xml /app/dspace-sword/
6868

6969
# 'dspace-swordv2' module POM
7070
RUN mkdir -p /app/dspace-swordv2
71-
ADD --chown=dspace dspace-swordv2/pom.xml /app/dspace-swordv2/
71+
COPY --chown=dspace dspace-swordv2/pom.xml /app/dspace-swordv2/
7272

7373
# Trigger the installation of all maven dependencies (hide download progress messages)
7474
# Maven flags here ensure that we skip final assembly, skip building test environment and skip all code verification checks.
@@ -80,3 +80,6 @@ RUN mvn --no-transfer-progress verify ${MAVEN_FLAGS}
8080
# This ensures when dspace:dspace is built, it will use the Maven local cache (~/.m2) for dependencies
8181
USER root
8282
RUN rm -rf /app/*
83+
84+
# Switch to initial user to drop root privileges (DL3002)
85+
USER dspace

Dockerfile.test

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ FROM ${DOCKER_REGISTRY}/dspace/dspace-dependencies:${DSPACE_VERSION} AS build
1919
ARG TARGET_DIR=dspace-installer
2020
WORKDIR /app
2121
# The dspace-installer directory will be written to /install
22+
USER root
2223
RUN mkdir /install \
2324
&& chown -Rv dspace: /install \
2425
&& chown -Rv dspace: /app
2526
USER dspace
2627
# Copy the DSpace source code (from local machine) into the workdir (excluding .dockerignore contents)
27-
ADD --chown=dspace . /app/
28+
COPY --chown=dspace . /app/
2829
# Build DSpace
2930
# Copy the dspace-installer directory to /install. Clean up the build to keep the docker image small
3031
RUN mvn --no-transfer-progress package && \
@@ -71,6 +72,6 @@ EXPOSE 8080 8000
7172
# Give java extra memory (2GB)
7273
ENV JAVA_OPTS=-Xmx2000m
7374
# enable JVM debugging via JDWP
74-
ENV JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8000
75+
ENV JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8000"
7576
# On startup, run DSpace Runnable JAR (uses the "dspace.dir" setting defined in "dspace__P__dir" env variable)
7677
ENTRYPOINT ["java", "-jar", "webapps/server-boot.jar"]

dspace/src/main/docker/dspace-postgres-loadsql/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ ENV POSTGRES_USER=${POSTGRES_USER}
2222
ENV POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
2323

2424
# Install curl which is necessary to load SQL file
25-
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
25+
RUN apt-get update \
26+
&& apt-get install -y --no-install-recommends curl \
27+
&& apt-get purge -y --auto-remove \
28+
&& rm -rf /var/lib/apt/lists/*
2629

2730
# Load a SQL dump. Set LOADSQL to a URL for the sql dump file.
2831
COPY loadsql.sh /docker-entrypoint-initdb.d/

dspace/src/main/docker/dspace-shibboleth/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ RUN a2enmod ssl proxy proxy_ajp proxy_http shib && \
3939
a2ensite dspace-vhost.conf
4040

4141
# Setup Shibboleth configs
42-
COPY shibboleth2.xml /etc/shibboleth/
43-
COPY attribute-map.xml /etc/shibboleth/
44-
RUN cd /etc/shibboleth/ \
45-
&& shib-keygen
42+
WORKDIR /etc/shibboleth
43+
COPY shibboleth2.xml .
44+
COPY attribute-map.xml .
45+
RUN shib-keygen
4646

4747
# Copy over our startup script
4848
COPY httpd-shibd-foreground.sh /usr/local/bin/

dspace/src/main/docker/dspace-solr/Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212

1313
ARG SOLR_VERSION=9.8
1414

15+
# NOTE: "solrconfigs" is a placeholder stage. It MUST be populated at runtime.
16+
# usage: docker build --build-context solrconfigs=[path-to-dspace/solr]
17+
# or: via "additional_contexts" in docker-compose
18+
FROM scratch AS solrconfigs
19+
1520
# NOTE: Cannot use the "-slim" image because it doesn't include the extra modules needed for DSpace (e.g. icu4j)
1621
FROM docker.io/solr:${SOLR_VERSION}
1722

@@ -36,8 +41,7 @@ RUN mkdir -p $AUTHORITY_CONFIGSET_PATH && \
3641
mkdir -p $SUGGESTION_CONFIGSET_PATH && \
3742
mkdir -p $AUDIT_CONFIGSET_PATH
3843

39-
# NOTE: "solrconfigs" MUST be passed in by docker-compose via "additional_contexts"
40-
# OR via "docker build --build-context solrconfigs=[path-to-dspace/solr]"
44+
# Copy configurations from the external 'solrconfigs' build context
4145
COPY --from=solrconfigs authority/conf/* $AUTHORITY_CONFIGSET_PATH/
4246
COPY --from=solrconfigs oai/conf/* $OAI_CONFIGSET_PATH/
4347
COPY --from=solrconfigs search/conf/* $SEARCH_CONFIGSET_PATH/

0 commit comments

Comments
 (0)