Skip to content

Commit 2b69cb8

Browse files
committed
Removed sbom, binutils, updated README
1 parent 1e26540 commit 2b69cb8

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

tiny-java-containers/README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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:
5657
1. 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

6263
2. 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
104105
pages.
105106

106107
How 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

109110
Let's move from the `helloworld` folder over to the `jwebserver` folder.
110111

@@ -139,7 +140,7 @@ jwebserver distroless-java de7f7efb6df4 4 minutes
139140
jwebserver temurin 643203bf8168 4 minutes ago 451MB
140141
jwebserver debian fa5bfa4b2e5e 4 minutes ago 932MB
141142
jwebserver 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
143144
jwebserver alpine.static 178081760470 6 minutes ago 21.6MB
144145
jwebserver distroless-static.static 84053f6323c1 6 minutes ago 15.8MB
145146
jwebserver scratch.static 98061f48037c 6 minutes ago 13.8MB
@@ -149,7 +150,7 @@ jwebserver distroless-java-base.dynamic 1aceeabbb329 7 minutes
149150

150151
Sorting by size, it's clear that the fully statically linked GraalVM Native
151152
Image 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
153154
of 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

168169
Running a container image is once again straight forward, just remember to map
169170
the 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

173174
or
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

177178
Using `curl` or your favourite tool you can hit `http://localhost:8000` to fetch
178179
the index.html file.

tiny-java-containers/jwebserver/Dockerfile.distroless-base.mostly

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM container-registry.oracle.com/graalvm/native-image:23 AS nativebuild
22
WORKDIR /build
33
# Build a native executable optimizing for size with `-Os`
4-
RUN native-image --static-nolibc -Os --enable-sbom=cyclonedx -m jdk.httpserver -o jwebserver.mostly
4+
RUN native-image --static-nolibc -Os -m jdk.httpserver -o jwebserver.mostly
55
RUN ls -lh jwebserver.mostly
66

77
FROM gcr.io/distroless/base-debian12

tiny-java-containers/jwebserver/Dockerfile.distroless-java-base.dynamic

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM container-registry.oracle.com/graalvm/native-image:23 AS nativebuild
22
WORKDIR /build
33
# Build a dynamically linked native executable optimizing for size with `-Os`
4-
RUN native-image -Os --enable-sbom=cyclonedx -m jdk.httpserver -o jwebserver.dynamic
4+
RUN native-image -Os -m jdk.httpserver -o jwebserver.dynamic
55
RUN ls -lh jwebserver.dynamic
66

77
FROM gcr.io/distroless/java-base-debian12

tiny-java-containers/jwebserver/Dockerfile.distroless-java-base.jlink

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
FROM container-registry.oracle.com/graalvm/jdk:23 AS build
2-
RUN microdnf install -y binutils
32
WORKDIR /build
43
# Build a runtime image optimized for size
54
RUN jlink \

tiny-java-containers/jwebserver/Dockerfile.distroless-static.static

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM container-registry.oracle.com/graalvm/native-image:23-muslib AS nativebuild
22
WORKDIR /build
33
# Build a statically linked native executable optimizing for size with `-Os`
4-
RUN native-image --static --libc=musl -Os --enable-sbom=cyclonedx -m jdk.httpserver -o jwebserver.static
4+
RUN native-image --static --libc=musl -Os -m jdk.httpserver -o jwebserver.static
55
RUN ls -lh jwebserver.static
66

77
FROM gcr.io/distroless/static-debian12

tiny-java-containers/jwebserver/Dockerfile.scratch.static

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM container-registry.oracle.com/graalvm/native-image:23-muslib AS nativebuild
22
WORKDIR /build
33
# Build a statically linked native executable optimizing for size with `-Os`
4-
RUN native-image --static --libc=musl -Os --enable-sbom=cyclonedx -m jdk.httpserver -o jwebserver.static
4+
RUN native-image --static --libc=musl -Os -m jdk.httpserver -o jwebserver.static
55
RUN ls -lh jwebserver.static
66

77
FROM scratch

tiny-java-containers/jwebserver/Dockerfile.scratch.static-upx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM container-registry.oracle.com/graalvm/native-image:23-muslib AS nativebuild
22
WORKDIR /build
33

44
# Build a statically linked native executable optimizing for size with `-Os`
5-
RUN native-image --static --libc=musl -Os --enable-sbom=cyclonedx -m jdk.httpserver -o jwebserver.static
5+
RUN native-image --static --libc=musl -Os -m jdk.httpserver -o jwebserver.static
66
RUN ls -lh jwebserver.static
77

88
# Install and use UPX

0 commit comments

Comments
 (0)