Skip to content

Distroless builds - httpserver-java21-distroless - #453

Open
Teodorandrei22 wants to merge 1 commit into
unikraft-cloud:mainfrom
Teodorandrei22:feat/httpserver-java21-distroless
Open

Distroless builds - httpserver-java21-distroless#453
Teodorandrei22 wants to merge 1 commit into
unikraft-cloud:mainfrom
Teodorandrei22:feat/httpserver-java21-distroless

Conversation

@Teodorandrei22

@Teodorandrei22 Teodorandrei22 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor
  • Add distroless variant of httpserver-java21 example.
  • Use gcr.io/distroless/java21-debian13 as runtime base.
  • Add Dockerfile, Kraftfile, README, and test file.

@Teodorandrei22
Teodorandrei22 force-pushed the feat/httpserver-java21-distroless branch 2 times, most recently from 72e5456 to 74e0a18 Compare August 25, 2026 12:00
@razvand
razvand requested a lite review from Copilot September 6, 2026 19:00
@razvand razvand self-assigned this Sep 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new server implementation has a real cross-thread visibility issue (startupDuration) and the distroless Dockerfile contains inaccurate/non-English header commentary that should be corrected.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a new httpserver-java21 variant that builds the app filesystem using a distroless Java 21 runtime image (gcr.io/distroless/java21-debian13) instead of a manually curated scratch rootfs, along with documentation and an end-to-end test.

Changes:

  • Introduces a distroless-based Dockerfile/rootfs and corresponding Kraftfile for deployment.
  • Adds a README documenting build/run steps for Unikraft Cloud (unikraft + legacy kraft CLIs).
  • Adds a Java HTTP server implementation and an e2e test validating it serves “Hello, World!”.
File summaries
File Description
httpserver-java21-distroless/Dockerfile Multi-stage build compiling Java 21 then using a distroless runtime stage.
httpserver-java21-distroless/Kraftfile Unikraft Cloud spec pointing rootfs to the Dockerfile and providing the Java cmd.
httpserver-java21-distroless/README.md Usage and customization guide for the distroless variant.
httpserver-java21-distroless/SimpleHttpServer.java Minimal Java HTTP server serving “Hello, World!” plus boot time info.
httpserver-java21-distroless/test_httpserver-java21-distroless.py E2E test building/running the example and asserting response content.
Review details

Suppressed comments (1)

httpserver-java21-distroless/SimpleHttpServer.java:34

  • response.getBytes() uses the platform default charset and is called multiple times. Use a deterministic charset and reuse the encoded bytes to avoid inconsistent encoding across environments and avoid duplicate work.
        String response = "Hello, World!\n[Unikraft Speed] Boot time: " + startupDuration + " ms\n";
        exchange.sendResponseHeaders(200, response.getBytes().length);
        OutputStream os = exchange.getResponseBody();
        os.write(response.getBytes());
        os.close();
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread httpserver-java21-distroless/SimpleHttpServer.java Outdated
Comment thread httpserver-java21-distroless/Dockerfile Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The Dockerfile’s distroless runtime stage is not pinned to --platform=linux/x86_64, which can produce an incompatible rootfs when building on non-x86_64 hosts.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 3
  • Review effort level: Lite

Comment thread httpserver-java21-distroless/Dockerfile Outdated
Comment thread httpserver-java21-distroless/SimpleHttpServer.java
Comment thread httpserver-java21-distroless/README.md
Add distroless variant of httpserver-java21 example.
Use gcr.io/distroless/java21-debian13 as runtime base.
Add Dockerfile, Kraftfile, README, and test file.

Signed-off-by: Teodor Constantinescu <constantinescu.teodor22@gmail.com>
@Teodorandrei22
Teodorandrei22 force-pushed the feat/httpserver-java21-distroless branch from 486b91c to 05bce35 Compare September 8, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants