Skip to content

Commit

Permalink
Dockerfile: Save unnecessary download in subsequent builds (replace '…
Browse files Browse the repository at this point in the history
…ADD' with 'wget') (#11)

To save data and speed up subsequent builds, we replace 'ADD' instruction with 'wget' command instead.

This works by taking advantage of the layer cache; ADD always download full file, 'wget' is a RUN output that gets cached.
  • Loading branch information
klo2k committed Aug 14, 2021
1 parent af0eb81 commit 621279f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@ FROM ubuntu:latest as downloader
ARG NEXUS_VERSION=3.33.0-01
ARG NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/nexus-${NEXUS_VERSION}-unix.tar.gz

ADD "${NEXUS_DOWNLOAD_URL}" "/tmp/nexus.tar.gz"
RUN mkdir /tmp/sonatype && \
# Download Nexus and other stuff we need later
# Use wget to improve performance (#11)
# Install wget
RUN apt update && apt install -y wget
# Download jars required for OrientDB startup error hack
RUN wget --quiet --directory-prefix=/tmp/ \
https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.5.0/jna-5.5.0.jar \
https://repo1.maven.org/maven2/net/java/dev/jna/jna-platform/5.5.0/jna-platform-5.5.0.jar
# Download + extract Nexus to "/tmp/sonatype/nexus" for use later
RUN wget --quiet --output-document=/tmp/nexus.tar.gz "${NEXUS_DOWNLOAD_URL}" && \
mkdir /tmp/sonatype && \
tar -zxf /tmp/nexus.tar.gz -C /tmp/sonatype && \
mv /tmp/sonatype/nexus-${NEXUS_VERSION} /tmp/sonatype/nexus
mv /tmp/sonatype/nexus-${NEXUS_VERSION} /tmp/sonatype/nexus && \
rm /tmp/nexus.tar.gz



Expand Down Expand Up @@ -49,8 +59,8 @@ RUN sed -i -e 's/^nexus-context-path=\//nexus-context-path=\/\${NEXUS_CONTEXT}/g

# Fix-up: Startup error with OrientDB on ARM - replace in-place 5.4.0 with 5.5.0 lib (reference is hard-coded in config files)
# http://bhamail.github.io/pinexus/nexussetup.html
ADD https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.5.0/jna-5.5.0.jar /opt/sonatype/nexus/system/net/java/dev/jna/jna/5.4.0/jna-5.4.0.jar
ADD https://repo1.maven.org/maven2/net/java/dev/jna/jna-platform/5.5.0/jna-platform-5.5.0.jar /opt/sonatype/nexus/system/net/java/dev/jna/jna-platform/5.4.0/jna-platform-5.4.0.jar
COPY --from=downloader /tmp/jna-5.5.0.jar /opt/sonatype/nexus/system/net/java/dev/jna/jna/5.4.0/jna-5.4.0.jar
COPY --from=downloader /tmp/jna-platform-5.5.0.jar /opt/sonatype/nexus/system/net/java/dev/jna/jna-platform/5.4.0/jna-platform-5.4.0.jar
RUN chmod 644 \
/opt/sonatype/nexus/system/net/java/dev/jna/jna/5.4.0/jna-5.4.0.jar \
/opt/sonatype/nexus/system/net/java/dev/jna/jna-platform/5.4.0/jna-platform-5.4.0.jar
Expand Down

0 comments on commit 621279f

Please sign in to comment.