You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/aac/java-mwa-guide.md
+29-27Lines changed: 29 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -417,38 +417,40 @@ In this configuration:
417
417
:::column-end:::
418
418
:::row-end:::
419
419
Containerization means that all dependencies for the app to function are encapsulated in a lightweight image that can be reliably deployed to a wide range of hosts. To containerize deployment, follow these recommendations:
420
+
420
421
-*Identify domain boundaries.* Start by identifying the domain boundaries within your monolithic application. This helps determine which parts of the application you can extract into separate services.
421
-
-*Create docker images.* When creating Docker images for your .NET services, use chiseled base images. These images contain only the minimal set of packages needed for .NET to run, which minimizes both the package size and the attack surface area.
422
-
-*Use multi-stage Dockerfiles.*Implement multi-stage Dockerfiles to separate build-time assets from the runtime container image. It helps to keep your production images small and secure.
423
-
-*Run as nonroot user.* Run your .NET containers as a nonroot user (via user name or UID, $APP_UID) to align with the principle of least privilege. It limits the potential effects of a compromised container.
422
+
-*Create docker images.* When creating Docker images for your Java services, use official OpenJDK base images. These images contain only the minimal set of packages needed for Java to run, which minimizes both the package size and the attack surface area.
423
+
-*Use multi-stage Dockerfiles.*Use a multi-stage Dockerfiles to separate build-time assets from the runtime container image. It helps to keep your production images small and secure. You can also use a pre-configured build server and copy the jar file into the container image.
424
+
-*Run as nonroot user.* Run your Java containers as a nonroot user (via user name or UID, $APP_UID) to align with the principle of least privilege. It limits the potential effects of a compromised container.
424
425
-*Listen on port 8080.* When running as a nonroot user, configure your application to listen on port 8080. It's a common convention for nonroot users.
425
426
-*Encapsulate dependencies.* Ensure that all dependencies for the app to function are encapsulated in the Docker container image. Encapsulation allows the app to be reliably deployed to a wide range of hosts.
426
427
-*Choose the right base images.* The base image you choose depends on your deployment environment. If you're deploying to Azure Container Apps, for instance, you need to use Linux Docker images.
427
-
For example, the reference implementation uses a [multi-stage](https://docs.docker.com/build/building/multi-stage/) build process. The initial stages compile and build the application using a full SDK image (`mcr.microsoft.com/dotnet/sdk:8.0-jammy`). The final runtime image is created from the `chiseled` base image, which excludes the SDK and build artifacts. The service runs as a nonroot user (`USER $APP_UID`) and exposes port 8080. The dependencies required for the application to operate are included within the Docker image, as evidenced by the commands to copy project files and restore packages. The choice of Linux-based images (`mcr.microsoft.com/dotnet/aspnet:8.0-jammy-chiseled`) for the runtime environment for deployment within Azure Container Apps, which requires Linux containers.
428
+
429
+
The reference implementation demonstrates a Docker build process for containerizing a Java application. This Dockerfile uses a single-stage build with the OpenJDK base image (`mcr.microsoft.com/openjdk/jdk:17-ubuntu`), which provides the necessary Java runtime environment.
430
+
431
+
The Dockerfile includes the following steps:
432
+
1.**Volume Declaration**: A temporary volume (`/tmp`) is defined, allowing for temporary file storage separate from the container's main filesystem.
433
+
2.**Copying Artifacts**: The application's JAR file (`email-processor.jar`) is copied into the container, along with the Application Insights agent (`applicationinsights-agent.jar`) for monitoring.
434
+
3.**Setting the Entrypoint**: The container is configured to run the application with the Application Insights agent enabled, using `java -javaagent` to monitor the application during runtime.
435
+
436
+
This Dockerfile keeps the image lean by only including runtime dependencies, suitable for deployment environments like **Azure Container Apps**, which support Linux-based containers.
437
+
428
438
429
439
```dockerfile
430
-
# Build in a separate stage to avoid copying the SDK into the final image
431
-
FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS build
*Figure 3. Architecture of the reference implementation. Download a [Visio file](https://arch-center.azureedge.net/modern-web-app-java-1.0.vsdx) of this architecture.*
460
462
461
463
>[!div class="nextstepaction"]
462
-
>[Modern Web App pattern for .NET reference implementation][reference-implementation]
464
+
>[Modern Web App pattern for Java reference implementation][reference-implementation]
0 commit comments