Skip to content

docs(dhi): add .NET and Java migration examples#25201

Open
sunnynagavo wants to merge 4 commits into
docker:mainfrom
sunnynagavo:dhi-migration-dotnet-java
Open

docs(dhi): add .NET and Java migration examples#25201
sunnynagavo wants to merge 4 commits into
docker:mainfrom
sunnynagavo:dhi-migration-dotnet-java

Conversation

@sunnynagavo
Copy link
Copy Markdown

This PR adds two new migration example guides under content/manuals/dhi/migration/examples/ for migrating applications to Docker Hardened Images (DHI):

  • .NET (dotnet.md)
  • Java (java.md)

Both guides follow the exact same structure as the existing Go, Python, and Node.js examples, with five Dockerfile variations each:

  • Before (Ubuntu)
  • Before (Wolfi)
  • Before (DOI)
  • After (multi-stage) — recommended
  • After (single-stage)

The .NET guide uses dhi.io/dotnet-sdk for build and dhi.io/dotnet-aspnet for runtime. The Java guide uses dhi.io/maven for build and dhi.io/eclipse-temurin for runtime.

The _index.md grid is updated to surface both new examples on the Migration examples landing page.

Checklist

  • Followed the existing format and front-matter conventions
  • Used DHI images available in the public DHI catalog (dhi.io/dotnet-sdk, dhi.io/dotnet-aspnet, dhi.io/maven, dhi.io/eclipse-temurin)
  • Updated the examples landing page (_index.md)

Adds before/after Dockerfile examples for migrating .NET and Java applications to Docker Hardened Images, following the existing Go/Python/Node.js examples format. Updates the examples index grid to include the new guides.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 28, 2026

Deploy Preview for docsdocker ready!

Name Link
🔨 Latest commit 7074b73
🔍 Latest deploy log https://app.netlify.com/projects/docsdocker/deploys/6a19c3025701780009919ece
😎 Deploy Preview https://deploy-preview-25201--docsdocker.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@craig-osterhout craig-osterhout added the status/review Pull requests that are ready for review label May 28, 2026
@craig-osterhout craig-osterhout requested a review from a team May 28, 2026 21:11
@craig-osterhout
Copy link
Copy Markdown
Contributor

/review

Copy link
Copy Markdown

@docker-agent docker-agent left a comment

Choose a reason for hiding this comment

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

Assessment: 🔴 CRITICAL

Two confirmed accuracy bugs in the new Dockerfile examples that would mislead users:

  1. java.mdBefore (Ubuntu) uses a JRE image as the build stage, but JRE images lack javac and Maven, so mvn -B package would fail.
  2. dotnet.mdAfter (single-stage) has a redundant cp step after dotnet publish -o /app. Since -o /app redirects output directly to /app, the source path /src/bin/Release/net8.0/publish/ doesn't exist. The 2>/dev/null || true silently suppresses the failure, producing a potentially broken image with no error.

Comment thread content/manuals/dhi/migration/examples/java.md Outdated
Comment thread content/manuals/dhi/migration/examples/dotnet.md Outdated
Copy link
Copy Markdown
Contributor

@craig-osterhout craig-osterhout left a comment

Choose a reason for hiding this comment

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

Thank you for raising this.
It looks like the existing examples, that this was based on, are using OS versions that are no longer available. I can get those updated.

For this PR, please ensure all new examples are able to run. The following repo is from an agent that tried to run samples. It includes the suggested fixes.

https://github.com/craig-osterhout/dotnet-java-dhi-verify

@sunnynagavo
Copy link
Copy Markdown
Author

Thank you for raising this. It looks like the existing examples, that this was based on, are using OS versions that are no longer available. I can get those updated.

For this PR, please ensure all new examples are able to run. The following repo is from an agent that tried to run samples. It includes the suggested fixes.

https://github.com/craig-osterhout/dotnet-java-dhi-verify

Thanks @craig-osterhout for reviewing, let me check that

sunnynagavo and others added 3 commits May 29, 2026 09:33
Apply verified fixes from craig-osterhout/dotnet-java-dhi-verify so the
.NET and Java migration examples actually build and run.

Java (java.md):
- Before (Ubuntu): switch builder + runtime to ubuntu:24.04 and install
  JDK/Maven (and JRE) via apt. The ubuntu/jre and ubuntu/jdk Pebble-based
  images have no shell or mvn and fail mvn -B package immediately.
- After (multi-stage): update DHI image refs to
  dhi.io/maven:3-jdk21-alpine3.22-dev and
  dhi.io/eclipse-temurin:21-alpine3.22 (the alpine3.21 tags do not exist).
- After (single-stage): same maven image update.

.NET (dotnet.md):
- Remove the Before (Ubuntu) tab. ubuntu/dotnet-sdk:8.0-24.04 does not
  exist; Canonical does not publish a .NET SDK image. Update the intro
  to describe four variations instead of five.
- Before (Wolfi): publish to /src/out and COPY from there. Chainguard
  images run as non-root and cannot create /app at publish time.
- After (multi-stage): update DHI image refs to
  dhi.io/dotnet:8-sdk-alpine3.22 and dhi.io/aspnetcore:8-alpine3.22.
- After (single-stage): update DHI image ref and remove redundant
  cp -r /src/bin/.../publish/* /app/ 2>/dev/null || true step, since
  dotnet publish -o /app already writes directly to /app.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…examples

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sunnynagavo
Copy link
Copy Markdown
Author

/review

@sunnynagavo
Copy link
Copy Markdown
Author

sunnynagavo commented May 29, 2026

Thank you for raising this. It looks like the existing examples, that this was based on, are using OS versions that are no longer available. I can get those updated.

For this PR, please ensure all new examples are able to run. The following repo is from an agent that tried to run samples. It includes the suggested fixes.

https://github.com/craig-osterhout/dotnet-java-dhi-verify

@craig-osterhout I looked at your repo, updated my PR accordingly and I also ran examples (built 9 images), to make sure everything works as expected, here are some screenshots.

For java,

image

Docker desktop showing Java images:
image

For Dotnet,

image

Docker desktop showing Dotnet images :

image

Let me know if you have any other comments.

@sunnynagavo
Copy link
Copy Markdown
Author

/review

@craig-osterhout , btw how to trigger the review ? looks like I dont have permissions to trigger docker agent ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/dhi status/review Pull requests that are ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants