This repo contains dead simple example with 3 modules: api, provider and consumer. After building, all modules are linked with jlink
and packed into a slim docker image without jre or jdk. Using jlink
is an absolutely optional step. A normal java application can be found in dist
folder.
To follow, see jigsaw guide.
The jlink
gives us docker image with incredible 50Mb size. As soon as openjdk:X-jdk-alpine
is released, size can be less than 40Mb. Note that jlink
creates statically linked application, therefore you must forget about cross-platform java applications and go with docker all the way from build to deploy.
$ ./build.sh
$ docker build . -t example
$ ./build.sh
$ docker build -f Dockerfile.wrap . -t example
java --module-path dist -m app
image/bin/java -m app/io.b3.app.Main
$ docker run --rm example
- Download jdk early-access build for Alpine Linux from http://jdk.java.net/11/
- Unpack the archive to
jdk-alpine
folder - Build
jdk-alpine
docker imagedocker build -f Dockerfile.ea . -t jdk-alpine
- Build app docker image
docker build -f Dockerfile.alpine . -t hi
UPDATES
- There is Alpine Linux JDK 11 available on JDK 11 Early-Access Builds page.
- There is an official project to provide a port of the JDK to the Alpine Linux.
- The image with
jdk9-apline
was canceled, but we will probably get alpine image with jdk10 after April 2018.