Last active
April 23, 2019 15:48
-
-
Save l1x/4ef0f022b60e2a51b80a8435f599367b to your computer and use it in GitHub Desktop.
JDK 13 on Alpine (Docker)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[centos@ip alpine]$ sudo docker tag f7e79af297d3 jdk-13-musl/jdk-version:v1 | |
[centos@ip alpine]$ sudo docker images | |
REPOSITORY TAG IMAGE ID CREATED SIZE | |
jdk-13-musl/hello-world v1 6a695924d06a 4 minutes ago 41.7MB | |
jdk-13-musl/jdk-version v1 f7e79af297d3 4 minutes ago 41.7MB | |
alpine 3.9 cdf98d1859c1 13 days ago 5.53MB | |
alpine latest cdf98d1859c1 13 days ago 5.53MB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:latest as build | |
ADD https://download.java.net/java/early_access/alpine/16/binaries/openjdk-13-ea+16_linux-x64-musl_bin.tar.gz /opt/jdk/ | |
RUN tar -xzvf /opt/jdk/openjdk-13-ea+16_linux-x64-musl_bin.tar.gz -C /opt/jdk/ | |
RUN ["/opt/jdk/jdk-13/bin/jlink", "--compress=2", \ | |
"--module-path", "/opt/jdk/jdk-13/jmods/", \ | |
"--add-modules", "java.base", \ | |
"--output", "/jlinked"] | |
FROM alpine:latest | |
COPY --from=build /jlinked /opt/jdk/ | |
ADD HelloWorld.class / | |
# CMD ["/opt/jdk/bin/java", "--version"] - to check JDK version | |
CMD ["/opt/jdk/bin/java", "HelloWorld"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HelloWorld { | |
public static void main(String[] args) { | |
// Prints "Hello, World" to the terminal window. | |
System.out.println("Hello, World"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/opt/jdk/jdk-13/bin/jlink --compress=2 --module-path /opt/jdk/jdk-13/jmods/ --add-modules java.base --output /jlinked |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment