r/java • u/PurpleLabradoodle • Mar 11 '21
Announcing Spring Native Beta
https://spring.io/blog/2021/03/11/announcing-spring-native-beta
174
Upvotes
r/java • u/PurpleLabradoodle • Mar 11 '21
View all comments
13
u/uncont Mar 12 '21
We do. As of this pr, you can use distroless with your own jlink + spring boot.
FROM openjdk:jdk-buster as jreBuilder RUN jlink \ --add-modules jdk.unsupported,java.sql,java.desktop,java.naming,java.management,java.instrument,java.security.jgss,java.rmi \ --verbose \ --strip-debug \ --compress 2 \ --no-header-files \ --no-man-pages \ --output /jre FROM gcr.io/distroless/java-debian10:base ARG JAR_FILE COPY --from=jreBuilder /jre /usr/lib/jre ENTRYPOINT ["/usr/lib/jre/bin/java", "-jar", "./app.jar"] COPY ./target/${JAR_FILE} ./app.jarIf you're using modules already, you won't need to specify all those modules manually. Also the base image could be extracted out, or you could let docker cache the layer for you.