From a31c955663a6357e7d056d4345c37569326212f0 Mon Sep 17 00:00:00 2001 From: Arne Franken Date: Tue, 23 Nov 2021 12:47:53 +0100 Subject: [PATCH] Use official alpine image with JDK11 This image is available in multiple architectures, i.e. arm64 and x86_64 Also create minimal JRE to use in final image. Fixs #313 --- docker/{src/main/docker => }/Dockerfile | 45 +++++++++++-------------- docker/pom.xml | 45 ++++++++++++++++--------- pom.xml | 2 -- 3 files changed, 48 insertions(+), 44 deletions(-) rename docker/{src/main/docker => }/Dockerfile (50%) diff --git a/docker/src/main/docker/Dockerfile b/docker/Dockerfile similarity index 50% rename from docker/src/main/docker/Dockerfile rename to docker/Dockerfile index b61b2f775..4e39d1eff 100644 --- a/docker/src/main/docker/Dockerfile +++ b/docker/Dockerfile @@ -14,43 +14,36 @@ # limitations under the License. # -FROM adoptopenjdk/openjdk11:${adoptopenjdk11.image.version} as staging_area +FROM alpine:3.15.0 as staging_area -# create a minimal jdk assembly with those modules that we need -RUN jlink \ - --module-path $JAVA_HOME/jmods \ +RUN apk --no-cache add openjdk11-jdk openjdk11-jmods + +ENV JAVA_MINIMAL="/opt/java-minimal" + +# build minimal JRE +RUN /usr/lib/jvm/java-11-openjdk/bin/jlink \ --verbose \ --add-modules java.base,java.logging,java.xml,jdk.unsupported,java.sql,java.naming,java.desktop,java.management,java.security.jgss,java.instrument \ --compress 2 \ --no-header-files \ --no-man-pages \ --strip-debug \ - --output /target/opt/jdk-minimal - -# add libz* files, so that we don't have to re-install that (not included in alpine-glibc) -RUN mkdir -p /target/usr/glibc-compat/lib; \ - cp /usr/glibc-compat/lib/libz* /target/usr/glibc-compat/lib + --output "$JAVA_MINIMAL" -# -# build the actual image -# -FROM frolvlad/alpine-glibc:${alpine-glibc.image.version} +FROM alpine:3.15.0 -# copy files prepared in the other container -COPY --from=staging_area /target / +ENV JAVA_HOME=/opt/java-minimal +ENV PATH="$PATH:$JAVA_HOME/bin" -# rebuild ld.so.cache to add libz -RUN /usr/glibc-compat/sbin/ldconfig +COPY --from=staging_area "$JAVA_HOME" "$JAVA_HOME" +COPY ./target/s3mock-exec.jar s3mock.jar -ENV LANG=en_US.UTF-8 \ - LANGUAGE=en_US:en \ - LC_ALL=en_US.UTF-8 \ - JAVA_HOME=/opt/jdk-minimal \ - PATH="$PATH:/opt/jdk-minimal/bin" \ - root=/s3mockroot +ENV LANG=en_US.UTF-8 +ENV LANGUAGE=en_US:en +ENV LC_ALL=en_US.UTF-8 +ENV root=/s3mockroot EXPOSE 9090 9191 -COPY maven /opt/ - -ENTRYPOINT java -XX:+UseContainerSupport -Xmx128m --illegal-access=warn -Djava.security.egd=file:/dev/./urandom -jar /opt/service/*.jar +# run the app on startup +ENTRYPOINT java -XX:+UseContainerSupport -Xmx128m --illegal-access=warn -Djava.security.egd=file:/dev/./urandom -jar s3mock.jar diff --git a/docker/pom.xml b/docker/pom.xml index a953f3bb3..679209869 100644 --- a/docker/pom.xml +++ b/docker/pom.xml @@ -51,22 +51,7 @@ s3mock ${docker.image.name} - ${project.basedir}/src/main/docker - - /opt - - - - - com.adobe.testing:s3mock - - service - 755 - - - - dir - + ${project.basedir}/Dockerfile ${project.version} latest @@ -82,6 +67,34 @@ maven-checkstyle-plugin + + org.apache.maven.plugins + maven-dependency-plugin + 3.2.0 + + + copy + prepare-package + + copy + + + + + + + com.adobe.testing + s3mock + exec + jar + false + ${project.build.directory} + s3mock-exec.jar + + + true + + diff --git a/pom.xml b/pom.xml index 4e2dc1341..c87fc1245 100644 --- a/pom.xml +++ b/pom.xml @@ -50,8 +50,6 @@ UTF-8 8 - jdk-11.0.11_9-alpine - alpine-3.13_glibc-2.33 adobe/s3mock false