Skip to content

Commit

Permalink
fixes #151 add jdk 17 docker file and update build.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
stevehu committed Oct 26, 2023
1 parent bc7a7a3 commit 94ec1e0
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion docker/Dockerfile-Debug
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 1 addition & 1 deletion docker/Dockerfile-Slim
Original file line number Diff line number Diff line change
@@ -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"]
46 changes: 46 additions & 0 deletions docker/Dockerfile17
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 94ec1e0

Please sign in to comment.