diff --git a/build.sh b/build.sh index e6dd7d2..c1d10c5 100755 --- a/build.sh +++ b/build.sh @@ -44,6 +44,7 @@ publish() { echo "Building Docker image with version $VERSION" docker build -t $IMAGE_NAME:$VERSION -t $IMAGE_NAME:latest -f ./docker/Dockerfile . --no-cache=true docker build -t $IMAGE_NAME:$VERSION-slim -f ./docker/Dockerfile-Slim . --no-cache=true + dokcer build -t $IMAGE_NAME:$VERSION-17 -f ./docker/Dockerfile.17 . --no-cache=true echo "Images built with version $VERSION" echo "Pushing image to DockerHub" docker push $IMAGE_NAME -a diff --git a/docker/Dockerfile b/docker/Dockerfile index b53ae94..76a5006 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -27,4 +27,4 @@ ENV PATH="$PATH:$JAVA_MINIMAL/bin" COPY --from=packager "$JAVA_MINIMAL" "$JAVA_MINIMAL" COPY /target/light-gateway.jar server.jar -CMD ["/bin/sh","-c","java -Dlight-4j-config-dir=/config -Dlogback.configurationFile=/config/logback.xml -jar /server.jar"] +CMD ["/bin/sh","-c","exec java -Dlight-4j-config-dir=/config -Dlogback.configurationFile=/config/logback.xml -jar /server.jar"] diff --git a/docker/Dockerfile-Debug b/docker/Dockerfile-Debug index 7bc28fd..e3b2248 100644 --- a/docker/Dockerfile-Debug +++ b/docker/Dockerfile-Debug @@ -1,3 +1,3 @@ FROM openjdk:11.0.3-slim ADD /target/light-proxy.jar server.jar -CMD ["/bin/sh","-c","java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 -Dlight-4j-config-dir=/config -Dlogback.configurationFile=/config/logback.xml -jar /server.jar"] +CMD ["/bin/sh","-c","exec java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 -Dlight-4j-config-dir=/config -Dlogback.configurationFile=/config/logback.xml -jar /server.jar"] diff --git a/docker/Dockerfile-Slim b/docker/Dockerfile-Slim index bc497e4..66475ef 100644 --- a/docker/Dockerfile-Slim +++ b/docker/Dockerfile-Slim @@ -1,3 +1,3 @@ FROM openjdk:11.0.3-slim ADD /target/light-gateway.jar server.jar -CMD ["/bin/sh","-c","java -Dlight-4j-config-dir=/config -Dlogback.configurationFile=/config/logback.xml -jar /server.jar"] +CMD ["/bin/sh","-c","exec java -Dlight-4j-config-dir=/config -Dlogback.configurationFile=/config/logback.xml -jar /server.jar"] diff --git a/docker/Dockerfile17 b/docker/Dockerfile17 new file mode 100644 index 0000000..cdf223d --- /dev/null +++ b/docker/Dockerfile17 @@ -0,0 +1,46 @@ +FROM amazoncorretto:17-alpine as corretto-jdk + +RUN { \ + java --version ; \ + echo "jlink version:" && \ + $JAVA_HOME/bin/jlink --version ; \ + } + +# required for strip-debug to work +RUN apk add --no-cache binutils + +# build modules distribution +RUN $JAVA_HOME/bin/jlink \ + --verbose \ + --add-modules \ + java.base,java.sql,java.naming,java.desktop,java.xml,jdk.crypto.cryptoki,jdk.crypto.ec,jdk.unsupported,java.management,java.security.jgss,java.net.http,java.net.http \ + --compress 2 \ + --strip-debug \ + --no-header-files \ + --no-man-pages \ + --output /customjre + +# Second stage, add only our minimal "JRE" distr and our app +FROM alpine + +ENV JAVA_HOME=/jre +ENV PATH="${JAVA_HOME}/bin:${PATH}" + +# copy JRE from the base image +COPY --from=corretto-jdk /customjre $JAVA_HOME + +# Add app user +ARG APPLICATION_USER=appuser +RUN adduser --no-create-home -u 1000 -D $APPLICATION_USER + +# Configure working directory +RUN mkdir /app && \ + chown -R $APPLICATION_USER /app + +USER 1000 + +COPY --chown=1000:1000 /target/light-gateway.jar /app/server.jar + +WORKDIR /app + +CMD ["/bin/sh","-c","exec java -Dlight-4j-config-dir=/config -Dlogback.configurationFile=/config/logback.xml -jar /app/server.jar"]