Skip to content

Commit

Permalink
Update path from 99 to 12
Browse files Browse the repository at this point in the history
  • Loading branch information
simonkurtz-MSFT committed Nov 21, 2023
1 parent b6cbf48 commit f23a0e3
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions docs/aca/12-optimize-containers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Our original `Dockerfile` looks like this:

=== "Backend.Api Dockerfile"
```Dockerfile
--8<-- "docs/aca/99-optimize-containers/Backend.Api.Dockerfile"
--8<-- "docs/aca/12-optimize-containers/Backend.Api.Dockerfile"
```

```shell
Expand All @@ -55,19 +55,19 @@ docker image list

This yields a sizable image at **222 MB**!

![Backend API Status Quo](../../assets/images/99-optimize-containers/backend-api-status-quo.png)
![Backend API Status Quo](../../assets/images/12-optimize-containers/backend-api-status-quo.png)

This image is comprised of two images, 452 packages, and has 19 vulnerabilities.

![Backend API Status Quo Image Stats](../../assets/images/99-optimize-containers/backend-api-status-quo-image-stats.png)
![Backend API Status Quo Image Stats](../../assets/images/12-optimize-containers/backend-api-status-quo-image-stats.png)

#### 1.2. Chiseled Images

Microsoft and Ubuntu's creator, Canonical, collaborated on the concept of a [chiseled image for .NET](https://learn.microsoft.com/en-us/dotnet/core/docker/container-images#scenario-based-images){target=_blank}. Take a general-purpose base image and start chiseling away until you are left with an image that contains nothing more than the bare necessities to run your workload. No shell, no package manager, no bloat.

=== "Backend.Api Dockerfile.chiseled"
```Dockerfile hl_lines="1 8"
--8<-- "docs/aca/99-optimize-containers/Backend.Api.Dockerfile.chiseled"
--8<-- "docs/aca/12-optimize-containers/Backend.Api.Dockerfile.chiseled"
```

Create a new file, `Dockerfile.chiseled` in the Backend Api root directory, then build the image again:
Expand All @@ -80,19 +80,19 @@ docker image list

Our image now stands at a much smaller **115 MB** - a drop of 107 MB and a size just 51.8% of the status quo image!

![Backend API Chiseled](../../assets/images/99-optimize-containers/backend-api-chiseled.png)
![Backend API Chiseled](../../assets/images/12-optimize-containers/backend-api-chiseled.png)

This image is comprised of one image, 331 packages, and has five vulnerabilities.

![Backend API Status Quo Image Stats](../../assets/images/99-optimize-containers/backend-api-chiseled-image-stats.png)
![Backend API Status Quo Image Stats](../../assets/images/12-optimize-containers/backend-api-chiseled-image-stats.png)

#### 1.3 Chiseled & Ahead-of-time (AOT) Compilation

[Ahead-of-time (AOT) compilation](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot){target_blank} was first introduced with .NET 7. AOT compiles the application to native code instead of Intermediate Language (IL). This means that we must have foresight as to what platform will be hosting the application. Our process is simplified by the fact that containers in Azure Container Apps are only Linux-hosted. By using native code, we will bypass the just-in-time (JIT) compiler when the container executes, which means we will have faster startup and a smaller memory footprint. It also means these images can run in environments where JIT compilation may not be permitted.

=== "Backend.Api Dockerfile.chiseled.aot"
```Dockerfile hl_lines="1 8"
--8<-- "docs/aca/99-optimize-containers/Backend.Api.Dockerfile.chiseled.aot"
--8<-- "docs/aca/12-optimize-containers/Backend.Api.Dockerfile.chiseled.aot"
```

Create a new file, `Dockerfile.chiseled.aot` in the Backend Api root directory, then build the image again:
Expand All @@ -109,12 +109,12 @@ docker image list

Another massive reduction takes the image down to a mere **16 MB** - a total drop of 206 MB and a size just 7.2% of the status quo image!

![Backend API Chiseled AOT](../../assets/images/99-optimize-containers/backend-api-chiseled-aot.png)
![Backend API Chiseled AOT](../../assets/images/12-optimize-containers/backend-api-chiseled-aot.png)

This image is comprised of one image, just 23 packages, and has nine vulnerabilities.
Notably, the four additional vulnerabilities are in the `openssl 3.0.2` package in this image.

![Backend API Status Quo Image Stats](../../assets/images/99-optimize-containers/backend-api-chiseled-aot-image-stats.png)
![Backend API Status Quo Image Stats](../../assets/images/12-optimize-containers/backend-api-chiseled-aot-image-stats.png)

#### 1.4 Deploying the new Status Quo

Expand Down Expand Up @@ -156,7 +156,7 @@ Our original `Dockerfile` looks like this:

=== "Frontend.Ui Dockerfile"
```Dockerfile
--8<-- "docs/aca/99-optimize-containers/Frontend.Ui.Dockerfile"
--8<-- "docs/aca/12-optimize-containers/Frontend.Ui.Dockerfile"
```

```shell
Expand All @@ -177,7 +177,7 @@ Skipping straight to AOT images:

=== "Frontend.Ui Dockerfile.chiseled.aot"
```Dockerfile hl_lines="1 8"
--8<-- "docs/aca/99-optimize-containers/Frontend.Ui.Dockerfile.chiseled.aot"
--8<-- "docs/aca/12-optimize-containers/Frontend.Ui.Dockerfile.chiseled.aot"
```

Create a new file, `Dockerfile.chiseled.aot` in the Frontend Ui root directory, then build the image again:
Expand All @@ -198,7 +198,7 @@ Our original `Dockerfile` looks like this:

=== "Backend.Svc Dockerfile"
```Dockerfile
--8<-- "docs/aca/99-optimize-containers/Backend.Svc.Dockerfile"
--8<-- "docs/aca/12-optimize-containers/Backend.Svc.Dockerfile"
```

```shell
Expand All @@ -219,7 +219,7 @@ Skipping straight to AOT images:

=== "Backend.Svc Dockerfile.chiseled.aot"
```Dockerfile hl_lines="1 8"
--8<-- "docs/aca/99-optimize-containers/Backend.Svc.Dockerfile.chiseled.aot"
--8<-- "docs/aca/12-optimize-containers/Backend.Svc.Dockerfile.chiseled.aot"
```

Create a new file, `Dockerfile.chiseled.aot` in the Backend Svc root directory, then build the image again:
Expand Down

0 comments on commit f23a0e3

Please sign in to comment.