Skip to content

Commit

Permalink
FEAT: Installer based docker build
Browse files Browse the repository at this point in the history
- added Dockerfile_installer which uses the JHOVE installer for a faster and more reliable way of building containers.
  • Loading branch information
carlwilson committed Sep 11, 2024
1 parent 75e7d9e commit f311d0d
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions Dockerfile_installer
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# See https://docs.docker.com/engine/userguide/eng-image/multistage-build/
# First build the app on a maven open jdk 11 container
ARG JHOVE_VERSION=1.32
FROM eclipse-temurin:11-jdk-alpine AS app-installer
ARG JHOVE_VERSION
ENV JHOVE_VERSION=${JHOVE_VERSION}

WORKDIR /tmp
COPY docker-install.xml .
RUN wget -O /tmp/jhove-installer.jar https://software.openpreservation.org/releases/jhove/jhove-${JHOVE_VERSION}.jar
RUN java -jar jhove-installer.jar docker-install.xml

# Now build a Java JRE for the Alpine application image
# https://github.com/docker-library/docs/blob/master/eclipse-temurin/README.md#creating-a-jre-using-jlink
FROM eclipse-temurin:11-jdk-alpine AS jre-builder

# Create a custom Java runtime
RUN "$JAVA_HOME/bin/jlink" \
--add-modules java.base,java.logging,java.xml,jdk.crypto.ec \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /javaruntime

# Now the final application image
FROM alpine:3

# Set for additional arguments passed to the java run command, no default
ARG JAVA_OPTS
ENV JAVA_OPTS=$JAVA_OPTS
# Specify the veraPDF REST version if you want to (to be used in build automation)
ARG JHOVE_VERSION
ENV JHOVE_VERSION=${JHOVE_VERSION}

# Copy the JRE from the previous stage
ENV JAVA_HOME=/opt/java/openjdk
ENV PATH "${JAVA_HOME}/bin:${PATH}"
COPY --from=jre-builder /javaruntime $JAVA_HOME

# Since this is a running network service we'll create an unprivileged account
# which will be used to perform the rest of the work and run the actual service:
RUN addgroup -S jhove && adduser -S -G jhove -h /opt/jhove jhove
RUN mkdir --parents /var/opt/jhove/logs && chown -R jhove:jhove /var/opt/jhove

USER jhove

WORKDIR /opt/jhove
# Copy the application from the previous stage
COPY --from=app-installer /opt/jhove/ /opt/jhove/

ENTRYPOINT ["/opt/jhove/jhove"]

0 comments on commit f311d0d

Please sign in to comment.