@@ -21,7 +21,8 @@ App](images/youtube.png)](https://youtu.be/6wYrAtngIVo)
2121## Prerequisites
2222
2323* x86 Linux (but the few binary dependencies could easily be changed for aarch64)
24- * Docker installed and running. It should work fine with [ podman] ( https://podman.io/ ) but it has not been tested.
24+ * Docker installed and running. It should work fine with
25+ [ podman] ( https://podman.io/ ) but it has not been tested.
2526
2627> NOTE: These instructions have only been tested on Linux x64.
2728
@@ -56,8 +57,8 @@ In a terminal, run:
56571 . The ` hello ` executable generated by GraalVM Native Image in the Dockerfile
5758 using the ` --static --libc=musl ` options is a fully self-contained
5859 executable. This means that it does not rely on any libraries in the host
59- operating system environment. This makes it easier to package in a variety of container images.
60- of Docker container images.
60+ operating system environment. This makes it easier to package in a variety of
61+ container images.
6162
62632 . You can see in the output of the Dockerfile build that ` ls -lh ` reports the
6364 ` hello ` executable is ~ 4.9MB. There's no JVM, no JARs, no JIT compiler and
@@ -72,8 +73,8 @@ In a terminal, run:
7273
7374### Container Images
7475
75- The size of the ` scratch ` -based container image is about the same size as the ` hello.upx `
76- executable since it adds little overhead.
76+ The size of the ` scratch ` -based container image is about the same size as the
77+ ` hello.upx ` executable since it adds little overhead.
7778
7879![ ] ( images/keyboard.jpg ) ` docker images hello `
7980
@@ -104,7 +105,7 @@ introduced in JDK 18 and build a containerized executable that serves up web
104105pages.
105106
106107How small can a containerized Java web server be? Would you believe a measly
107- 4.4MB ? Let's see.
108+ 3.9 MB ? Let's see.
108109
109110Let's move from the ` helloworld ` folder over to the ` jwebserver ` folder.
110111
@@ -139,7 +140,7 @@ jwebserver distroless-java de7f7efb6df4 4 minutes
139140jwebserver temurin 643203bf8168 4 minutes ago 451MB
140141jwebserver debian fa5bfa4b2e5e 4 minutes ago 932MB
141142jwebserver distroless-java-base.jlink c3113c2400ea 5 minutes ago 122MB
142- jwebserver scratch.static-upx 75b3bb3249f3 5 minutes ago 4.12MB
143+ jwebserver scratch.static-upx 75b3bb3249f3 5 minutes ago 3.9MB
143144jwebserver alpine.static 178081760470 6 minutes ago 21.6MB
144145jwebserver distroless-static.static 84053f6323c1 6 minutes ago 15.8MB
145146jwebserver scratch.static 98061f48037c 6 minutes ago 13.8MB
@@ -149,7 +150,7 @@ jwebserver distroless-java-base.dynamic 1aceeabbb329 7 minutes
149150
150151Sorting by size, it's clear that the fully statically linked GraalVM Native
151152Image generated executable that's compressed and packaged on ` scratch `
152- (` scratch.static-upx ` ) is the smallest at just 4.71MB , less than 4% of the size
153+ (` scratch.static-upx ` ) is the smallest at just 3.9 MB , less than 4% of the size
153154of the ` jlink ` version (` distroless-java-base.jlink ` ) running on the JVM.
154155
155156| Base Image | App Version | Size (MB) |
@@ -163,16 +164,16 @@ of the `jlink` version (`distroless-java-base.jlink`) running on the JVM.
163164| Alpine | native * fully* static linked | 21.60 |
164165| Distroless Static | native * fully* static linked | 15.80 |
165166| Scratch | native * fully* static linked | 13.80 |
166- | Scratch | * compressed* native * fully* static | 4.12 |
167+ | Scratch | * compressed* native * fully* static | 3.90 |
167168
168169Running a container image is once again straight forward, just remember to map
169170the server port, e.g.:
170171
171- ![ ] ( images/keyboard.jpg ) ` docker run --rm -p8000:8000 jwebserver:scratch.static `
172+ ![ ] ( images/keyboard.jpg ) ` docker run --init -- rm -p8000:8000 jwebserver:scratch.static `
172173
173174or
174175
175- ![ ] ( images/keyboard.jpg ) ` docker run --rm -p8000:8000 jwebserver:scratch.static-upx `
176+ ![ ] ( images/keyboard.jpg ) ` docker run --init -- rm -p8000:8000 jwebserver:scratch.static-upx `
176177
177178Using ` curl ` or your favourite tool you can hit ` http://localhost:8000 ` to fetch
178179the index.html file.
0 commit comments