Merge branch 'main' into 9.0-preview7

This commit is contained in:
Matt Thalman 2024-08-13 07:41:43 -05:00 коммит произвёл GitHub
Родитель 95b3d9789a a9958a525f
Коммит dda2aa647d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
34 изменённых файлов: 170 добавлений и 154 удалений

Просмотреть файл

@ -1,16 +1,16 @@
{
"default": true,
"MD013": false, // line length
"MD024": { // no-duplicate-heading Multiple headings with the same content
"siblings_only": true
},
"MD033": false, // no inline HTML
// The following rules are disabled to allow the linter to be enabled.
// Follow-up work will be done to enable these rules and clean up the violations.
"MD001": false, // heading-increment Heading levels should only increment by one level at a time
"MD013": false, // line length
"MD022": false, // blanks-around-headings Headings should be surrounded by blank lines
"MD024": false, // no-duplicate-heading Multiple headings with the same content
"MD025": false, // single-title/single-h1 Multiple top-level headings in the same document
"MD028": false, // no-blanks-blockquote Blank line inside blockquote
"MD034": false, // no-bare-urls Bare URL used
"MD036": false, // no-emphasis-as-heading Emphasis used instead of a heading
"MD041": false, // first-line-heading/first-line-h1 First line in a file should be a top-level heading
}

Просмотреть файл

@ -251,8 +251,6 @@ Tag | Dockerfile
You can retrieve a list of all available tags for dotnet/aspnet at https://mcr.microsoft.com/v2/dotnet/aspnet/tags/list.
<!--End of generated tags-->
For tags contained in the old dotnet/core/aspnet repository, you can retrieve a list of those tags at https://mcr.microsoft.com/v2/dotnet/core/aspnet/tags/list.
*Tags not listed in the table above are not supported. See the [Supported Tags Policy](https://github.com/dotnet/dotnet-docker/blob/main/documentation/supported-tags.md)*
# Support

Просмотреть файл

@ -23,7 +23,7 @@ You can use C# or F# to write .NET apps.
You are invited to [contribute new features](https://github.com/dotnet/core/blob/master/CONTRIBUTING.md), fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.
> https://docs.microsoft.com/dotnet/core/
> [.NET Documentation](https://docs.microsoft.com/dotnet/core/)
Watch [discussions](https://github.com/dotnet/dotnet-docker/discussions/categories/announcements) for Docker-related .NET announcements.

Просмотреть файл

@ -164,8 +164,6 @@ Tags | Dockerfile | OS Version
You can retrieve a list of all available tags for dotnet/runtime-deps at https://mcr.microsoft.com/v2/dotnet/runtime-deps/tags/list.
<!--End of generated tags-->
For tags contained in the old dotnet/core/runtime-deps repository, you can retrieve a list of those tags at https://mcr.microsoft.com/v2/dotnet/core/runtime-deps/tags/list.
*Tags not listed in the table above are not supported. See the [Supported Tags Policy](https://github.com/dotnet/dotnet-docker/blob/main/documentation/supported-tags.md)*
# Support

Просмотреть файл

@ -207,8 +207,6 @@ Tag | Dockerfile
You can retrieve a list of all available tags for dotnet/runtime at https://mcr.microsoft.com/v2/dotnet/runtime/tags/list.
<!--End of generated tags-->
For tags contained in the old dotnet/core/runtime repository, you can retrieve a list of those tags at https://mcr.microsoft.com/v2/dotnet/core/runtime/tags/list.
*Tags not listed in the table above are not supported. See the [Supported Tags Policy](https://github.com/dotnet/dotnet-docker/blob/main/documentation/supported-tags.md)*
# Support

Просмотреть файл

@ -113,8 +113,6 @@ aspnetapp-8.0-nanoserver-1809, aspnetapp-nanoserver-1809, aspnetapp-8.0, aspneta
You can retrieve a list of all available tags for dotnet/samples at https://mcr.microsoft.com/v2/dotnet/samples/tags/list.
<!--End of generated tags-->
For tags contained in the old dotnet/core/samples repository, you can retrieve a list of those tags at https://mcr.microsoft.com/v2/dotnet/core/samples/tags/list.
*Tags not listed in the table above are not supported. See the [Supported Tags Policy](https://github.com/dotnet/dotnet-docker/blob/main/documentation/supported-tags.md)*
# Support

Просмотреть файл

@ -177,8 +177,6 @@ Tag | Dockerfile
You can retrieve a list of all available tags for dotnet/sdk at https://mcr.microsoft.com/v2/dotnet/sdk/tags/list.
<!--End of generated tags-->
For tags contained in the old dotnet/core/sdk repository, you can retrieve a list of those tags at https://mcr.microsoft.com/v2/dotnet/core/sdk/tags/list.
*Tags not listed in the table above are not supported. See the [Supported Tags Policy](https://github.com/dotnet/dotnet-docker/blob/main/documentation/supported-tags.md)*
# Support

Просмотреть файл

@ -152,7 +152,7 @@ flowchart TD
Here's an example configuration based off of a simple ASP.NET Core app:
**.csproj**
### *.csproj
```diff
<PropertyGroup>
@ -162,7 +162,7 @@ Here's an example configuration based off of a simple ASP.NET Core app:
</PropertyGroup>
```
**Dockerfile**
### Dockerfile
```diff
# Learn about building .NET container images:

Просмотреть файл

@ -100,8 +100,9 @@ FROM mcr.microsoft.com/cbl-mariner/base/core:2.0
COPY --from=distroless / /distroless
```
Note the last instruction copies the entire contents of the distroless container's filesystem to the `/distroless` directory in the wrapper.
This will be the target location used when executing commands.
> [!NOTE]
> The last instruction copies the entire contents of the distroless container's filesystem to the `/distroless` directory in the wrapper.
> This will be the target location used when executing commands.
Next, build the Dockerfile, specifying the distroless image tag you wish to inspect:

Просмотреть файл

@ -11,23 +11,23 @@ By default, these images do not include `icu` or `tzdata`, meaning that these im
Apps that require globalization support can use the `extra` image variant of the [dotnet/runtime-deps](https://hub.docker.com/_/microsoft-dotnet-runtime-deps/) images. Because this is only available with `runtime-deps` images, it requires a [self-contained deployment](https://learn.microsoft.com/dotnet/core/deploying/#publish-self-contained) of the application.
Alpine, Azure Linux, and Ubuntu Chiseled images also come in `extra`, `composite`, and `aot` variants (see below).
### Distroless
## Distroless
[Ubuntu Chiseled](https://ubuntu.com/engage/chiselled-ubuntu-images-for-containers) and [Azure Linux](./azurelinux.md) distroless .NET images contain only the minimum set of libraries necessary to run .NET applications with everything else removed.
For more information, see the [Distroless .NET images documentation](./distroless.md).
### `extra` (.NET 8.0+)
## `extra` (.NET 8.0+)
For apps that depend on globalization functionality, the `extra` image variant is offered for [Ubuntu Chiseled](./ubuntu-chiseled.md) and [Azure Linux](./azurelinux.md) distroless `runtime-deps`, `runtime`, and `aspnet` images as well as `runtime-deps` images for Alpine Linux.
These `extra` images contain everything that the default images do, plus `icu` and `tzdata`.
### `composite` (.NET 8.0+)
## `composite` (.NET 8.0+)
ASP.NET Core Composite images provide a smaller size on disk while keeping the performance of the default [ReadyToRun (R2R) setting](https://learn.microsoft.com/dotnet/core/deploying/ready-to-run).
The caveat is that the composite images have tighter version coupling. This means the final app run on them cannot use handpicked custom versions of the framework and/or ASP.NET assemblies that are built into the composite binary.
For a full technical description on how the composites work, we have a [feature doc here](https://github.com/dotnet/runtime/blob/main/docs/design/features/readytorun-composite-format-design.md).
### (Preview) `aot` (.NET 8.0+)
## (Preview) `aot` (.NET 8.0+)
The `aot` images provide an optimized deployment size for [Native AOT](https://learn.microsoft.com/dotnet/core/deploying/native-aot/) compiled .NET apps.
Native AOT has the lowest size, startup time, and memory footprint of all .NET deployment models.

Просмотреть файл

@ -144,7 +144,7 @@ The `VSS_NUGET_EXTERNAL_FEED_ENDPOINTS` environment variable is a well-known var
Instead, the credentials for `customfeed` are defined in the Dockerfile by making use of an `ARG` for the access token:
_Linux_
### Linux
```Dockerfile
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
@ -170,7 +170,7 @@ COPY --from=build /app/out ./
ENTRYPOINT ["dotnet", "dotnetapp.dll"]
```
_Windows_
### Windows
```Dockerfile
# escape=`
@ -207,7 +207,8 @@ COPY --from=build /app/out ./
ENTRYPOINT ["dotnet", "dotnetapp.dll"]
```
_Note that a script is called to install the Credential Provider. When `dotnet restore` is run, the Credential Provider is invoked to resolve the credentials and it retrieves them from the `VSS_NUGET_EXTERNAL_FEED_ENDPOINTS` environment variable._
> [!NOTE]
> A script is called to install the Credential Provider. When `dotnet restore` is run, the Credential Provider is invoked to resolve the credentials and it retrieves them from the `VSS_NUGET_EXTERNAL_FEED_ENDPOINTS` environment variable.
Before running `docker build`, first populate the `FEED_ACCESSTOKEN` environment variable with a [personal access token](https://docs.microsoft.com/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate). Then, this Dockerfile would be built using this command:

Просмотреть файл

@ -52,7 +52,9 @@ They include:
- Debian, unless specified (like `8.0-alpine`).
- All [supported architectures](supported-platforms.md#architectures).
> Note: Since .NET 8, these multi-platform tags **specifically exclude all Windows versions** due to `containerd`'s platform matching algorithm for Windows hosts.
> [!NOTE]
> Since .NET 8, these multi-platform tags **specifically exclude all Windows versions** due to `containerd`'s platform matching algorithm for Windows hosts.
Please see [#4492 (Switch multi-platform tags to Linux only)](https://github.com/dotnet/dotnet-docker/issues/4492) for more context.
If you are using Windows, you will need to explicitly specify an OS Version with a single-platform tag like so:
@ -90,11 +92,11 @@ Examples:
- `6.0-alpine`
- `8.0-alpine`
Notes:
- New versions of Alpine will be published with version-specific tags (e.g. `6.0-alpine3.20`).
- Floating tag (e.g. `6.0-alpine`) will be updated with the new Alpine version a month later.
- Tag changes will be [announced](https://github.com/dotnet/dotnet-docker/discussions/categories/announcements) so that users know when the tags they want are available.
> [!NOTE]
>
> - New versions of Alpine will be published with version-specific tags (e.g. `6.0-alpine3.20`).
> - Floating tag (e.g. `6.0-alpine`) will be updated with the new Alpine version a month later.
> - Tag changes will be [announced](https://github.com/dotnet/dotnet-docker/discussions/categories/announcements) so that users know when the tags they want are available.
### `<Major.Minor.Patch .NET Version>`
@ -131,10 +133,10 @@ For more information, see the [Image Variants documentation](./image-variants.md
These "floating version" `latest` tag references an image with the latest `Major.Minor.Patch` .NET version, while operating system and architecture will be chosen based on the requesting environment.
Notes:
- The `latest` tag references the latest stable release.
- In the `nightly` image repo, it may reference the latest preview release.
> [!NOTE]
>
> - The `latest` tag references the latest stable release.
> - In the `nightly` image repo, it may reference the latest preview release.
## Tag policies
@ -149,12 +151,12 @@ Examples:
- `6.0.32`
- `8.0.7-alpine3.20`
Notes:
- These tags are considered _fixed tags_ since they reference a specific .NET patch version.
- They are updated in response to base image updates (like a Debian base image) for the supported life of the image (typically one month).
- The .NET components within the image will not be updated.
- In the rare event that .NET components are updated before the next regular .NET service release, then a new image with a `-1` tag will be created. The same practice will repeat itself if necessary (with `-2` and then `-3` tags).
> [!NOTE]
>
> - These tags are considered _fixed tags_ since they reference a specific .NET patch version.
> - They are updated in response to base image updates (like a Debian base image) for the supported life of the image (typically one month).
> - The .NET components within the image will not be updated.
> - In the rare event that .NET components are updated before the next regular .NET service release, then a new image with a `-1` tag will be created. The same practice will repeat itself if necessary (with `-2` and then `-3` tags).
### Floating version tags
@ -165,11 +167,11 @@ Examples:
- `6.0`
- `8.0-alpine3.20`
Notes:
- These tags are considered _floating tags_ since they do not reference a specific .NET patch version.
- They are updated in response to base image updates (like a Debian base image) for the supported life of the .NET release.
- The .NET components within the image will be updated, which typically occurs on Patch Tuesday.
> [!NOTE]
>
> - These tags are considered _floating tags_ since they do not reference a specific .NET patch version.
> - They are updated in response to base image updates (like a Debian base image) for the supported life of the .NET release.
> - The .NET components within the image will be updated, which typically occurs on Patch Tuesday.
### OS tags and base image updates
@ -180,12 +182,12 @@ Examples:
- `6.0-jammy`
- `8.0-alpine3.20`
Notes:
- These tags are updated in response to base image updates (like an Ubuntu base image) for the supported life of the .NET release.
- Digest pinning is required to request a specific patch of an operating system (e.g. `mcr.microsoft.com/dotnet/runtime@sha256:4d3d5a5131a0621509ab8a75f52955f2d0150972b5c5fb918e2e59d4cb9a9823`).
- If an image is only available for one operating system, then the operating system will be omitted from the tag.
- For [Debian](https://en.wikipedia.org/wiki/Debian_version_history) and [Ubuntu](https://en.wikipedia.org/wiki/Ubuntu_version_history) images, release codenames are used instead of version numbers.
> [!NOTE]
>
> - These tags are updated in response to base image updates (like an Ubuntu base image) for the supported life of the .NET release.
> - Digest pinning is required to request a specific patch of an operating system (e.g. `mcr.microsoft.com/dotnet/runtime@sha256:4d3d5a5131a0621509ab8a75f52955f2d0150972b5c5fb918e2e59d4cb9a9823`).
> - If an image is only available for one operating system, then the operating system will be omitted from the tag.
> - For [Debian](https://en.wikipedia.org/wiki/Debian_version_history) and [Ubuntu](https://en.wikipedia.org/wiki/Ubuntu_version_history) images, release codenames are used instead of version numbers.
### Windows tags

Просмотреть файл

@ -71,6 +71,8 @@ $myImage="<insert-my-image-tag>"
&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/dotnet/dotnet-docker/main/documentation/scripts/resolve-image-digest.ps1'))) $myImage
```
#### Resolving multi-arch tags
If the script above returns an error indicating it's unable to resolve a multi-arch tag, you'll need to provide extra parameters to the script.
The following scripts indicate how to do that.
@ -81,7 +83,7 @@ You only need the first three parts of the version number.
In the case of Windows Server 2022, it's `10.0.20348`.
You can use a wildcard to indicate the rest of the version number.
#### macOS/Linux
##### macOS/Linux
Requires [PowerShell to be installed](https://learn.microsoft.com/powershell/scripting/install/installing-powershell-on-linux).
@ -93,7 +95,7 @@ osVersion="<windows-version>" # Only used for Windows containers (e.g. "10.0.203
curl -sSL https://raw.githubusercontent.com/dotnet/dotnet-docker/main/documentation/scripts/resolve-image-digest.ps1 | pwsh /dev/stdin $myImage -Os $os -Architecture $arch -OsVersion $osVersion
```
#### Windows
##### Windows
```powershell
$myImage="<insert-my-image-tag>"

Просмотреть файл

@ -1 +1,3 @@
# .NET Docker Pipelines
The contents of the `pipelines` folder are used by the .NET Core engineering infrastructure to build and publish the images.

Просмотреть файл

@ -11,4 +11,4 @@ You can use C# or F# to write .NET apps.
You are invited to [contribute new features](https://github.com/dotnet/core/blob/master/CONTRIBUTING.md), fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.
> https://docs.microsoft.com/dotnet/core/
> [.NET Documentation](https://docs.microsoft.com/dotnet/core/)

Просмотреть файл

@ -27,9 +27,7 @@ if !IS_PRODUCT_FAMILY:{{InsertTemplate("FeaturedTags.md", commonArgs)}}
{{if !IS_PRODUCT_FAMILY:
# Full Tag Listing
{{if ARGS["readme-host"] = "github":<!--End of generated tags-->
{{if !(isMonitor || isAspireDashboard):For tags contained in the old dotnet/core{{if isNightlyRepo:-nightly}}/{{SHORT_REPO}} repository, you can retrieve a list of those tags at https://mcr.microsoft.com/v2/dotnet/core{{if isNightlyRepo:-nightly}}/{{SHORT_REPO}}/tags/list.
}}*Tags not listed in the table above are not supported. See the [Supported Tags Policy](https://github.com/dotnet/dotnet-docker/blob/main/documentation/supported-tags.md)*
*Tags not listed in the table above are not supported. See the [Supported Tags Policy](https://github.com/dotnet/dotnet-docker/blob/main/documentation/supported-tags.md)*
^elif ARGS["readme-host"] = "dockerhub":
View the current tags at the [Microsoft Artifact Registry portal](https://mcr.microsoft.com/product/{{REPO}}/tags) or on [GitHub](https://github.com/dotnet/dotnet-docker/blob/{{if isNightlyRepo:nightly^else:main}}/README.{{SHORT_REPO}}.md#full-tag-listing).
}}}}

Просмотреть файл

@ -2,7 +2,8 @@
This sample demonstrates how to build container images for ASP.NET Core web apps. See [.NET Docker Samples](../README.md) for more samples.
> Note: .NET 8 container images use port `8080`, by default. Previous .NET versions used port `80`. The instructions for the sample assume the use of port `8080`.
> [!NOTE]
> .NET 8 container images use port `8080`, by default. Previous .NET versions used port `80`. The instructions for the sample assume the use of port `8080`.
## Run the sample image
@ -39,7 +40,8 @@ Supported with .NET Core 1.0+
ASPNETCORE_URLS=http://+:80
```
> Note: `ASPNETCORE_URLS` overwrites `ASPNETCORE_HTTP_PORTS` if set.
> [!NOTE]
> `ASPNETCORE_URLS` overwrites `ASPNETCORE_HTTP_PORTS` if set.
These environment variables are used in [.NET 8](https://github.com/dotnet/dotnet-docker/blob/6da64f31944bb16ecde5495b6a53fc170fbe100d/src/runtime-deps/8.0/bookworm-slim/amd64/Dockerfile#L7C5-L7C31) and [.NET 6](https://github.com/dotnet/dotnet-docker/blob/6da64f31944bb16ecde5495b6a53fc170fbe100d/src/runtime-deps/6.0/bookworm-slim/amd64/Dockerfile#L5) Dockerfiles, respectively.
@ -64,7 +66,8 @@ info: Microsoft.Hosting.Lifetime[0]
After the application starts, navigate to `http://localhost:8000` in your web browser. You can also view the ASP.NET Core site running in the container from another machine with a local IP address such as `http://192.168.1.18:8000`.
> Note: ASP.NET Core apps (in official images) listen to [port 8080 by default](https://github.com/dotnet/dotnet-docker/blob/6da64f31944bb16ecde5495b6a53fc170fbe100d/src/runtime-deps/8.0/bookworm-slim/amd64/Dockerfile#L7), starting with .NET 8. The [`-p` argument](https://docs.docker.com/engine/reference/commandline/run/#publish) in these examples maps host port `8000` to container port `8080` (`host:container` mapping). The container will not be accessible without this mapping. ASP.NET Core can be [configured to listen on a different or additional port](https://learn.microsoft.com/aspnet/core/fundamentals/servers/kestrel/endpoints).
> [!NOTE]
> ASP.NET Core apps (in official images) listen to [port 8080 by default](https://github.com/dotnet/dotnet-docker/blob/6da64f31944bb16ecde5495b6a53fc170fbe100d/src/runtime-deps/8.0/bookworm-slim/amd64/Dockerfile#L7), starting with .NET 8. The [`-p` argument](https://docs.docker.com/engine/reference/commandline/run/#publish) in these examples maps host port `8000` to container port `8080` (`host:container` mapping). The container will not be accessible without this mapping. ASP.NET Core can be [configured to listen on a different or additional port](https://learn.microsoft.com/aspnet/core/fundamentals/servers/kestrel/endpoints).
You can see the app running via `docker ps`.

Просмотреть файл

@ -79,7 +79,8 @@ The `--platform` argument is the best way to specify the desired architecture. T
In addition, Docker [Buildkit exposes multiple environment variables](https://github.com/dotnet/dotnet-docker/pull/4387#issuecomment-1416565213) that can be used to further conditionalize behavior. These environment variables can be controlled with the pattern demonstrated in [Dockerfile](https://github.com/mthalman/dredge/blob/main/src/Valleysoft.Dredge/Dockerfile). As mentioned, .NET doesn't support being run in emulation. The pattern in that Dockerfile results in the SDK always being run natively while the final image is affected by the `--platform` switch. This model also has the best performance since the bulk of computation is run natively.
> Note: We are enabling the following model in a future release: https://github.com/dotnet/dotnet-docker/issues/4388#issuecomment-1421401384.
> [!NOTE]
> We are enabling this [model](https://github.com/dotnet/dotnet-docker/issues/4388#issuecomment-1421401384) in a future release.
## .NET and QEMU
@ -87,4 +88,4 @@ Docker Desktop uses [QEMU](https://www.qemu.org/) for emulation, for example run
As a result, we need a reliable pattern that can produce multiple variants of images on one machine, but that doesn't use emulation. That's what this document describes.
Context: https://gitlab.com/qemu-project/qemu/-/issues/249
> [QEMU context](https://gitlab.com/qemu-project/qemu/-/issues/249)

Просмотреть файл

@ -45,7 +45,8 @@ There are two primary ways to test within the workflow of an application contain
This is different than running tests within a [.NET SDK container](../run-tests-in-sdk-container.md), which establishes a generic environment (which also works well). The rest of this document is focused on running tests within the same container environment as the application.
> Note: See [Establishing docker environment](../establishing-docker-environment.md) for more information on correctly configuring Dockerfiles and `docker build` commands.
> [!NOTE]
> See [Establishing docker environment](../establishing-docker-environment.md) for more information on correctly configuring Dockerfiles and `docker build` commands.
## Running tests as an opt-in stage

Просмотреть файл

@ -18,7 +18,8 @@ docker build --pull -t aspnetapp -f Dockerfile .
Create an ACR registry per the instructions at [Push Docker Images to Azure Container Registry](push-image-to-acr.md). The following is a summarized version of those instructions.
> Note: Change the password location and the user account ("rich" and "richlander") example values in your environment.
> [!NOTE]
> Change the password location and the user account ("rich" and "richlander") example values in your environment.
```console
az login

Просмотреть файл

@ -35,7 +35,7 @@ System.Globalization.CultureNotFoundException: Only the invariant culture is sup
en-us is an invalid culture identifier.
```
This is by design. `Microsoft.Data.SqlClient` requires ICU to be installed. See https://github.com/dotnet/SqlClient/issues/220 for more information.
This is by design. `Microsoft.Data.SqlClient` requires ICU to be installed. See this [Sql Client issue](https://github.com/dotnet/SqlClient/issues/220) for more information.
### Alpine images
@ -54,7 +54,7 @@ RUN apk add --no-cache \
### Ubuntu chiseled images
ICU can be added to an Ubuntu chiseled image, as demonstrated by https://github.com/ubuntu-rocks/dotnet/issues/21.
ICU can be added to an Ubuntu chiseled image, as demonstrated in this [chisel issue](https://github.com/ubuntu-rocks/dotnet/issues/21).
## Tzdata

Просмотреть файл

@ -59,10 +59,9 @@ dotnet dev-certs https --trust
```
> [!NOTE]
> `dotnet dev-certs https --trust` is only supported on macOS and Windows. You need to trust certs on Linux in the way that is supported by your distro. It is likely that you need to trust the certificate in your browser.
> [!NOTE]
> `<CREDENTIAL_PLACEHOLDER>` is used as a stand-in for a password of your own choosing.
>
> - `dotnet dev-certs https --trust` is only supported on macOS and Windows. You need to trust certs on Linux in the way that is supported by your distro. It is likely that you need to trust the certificate in your browser.
> - `<CREDENTIAL_PLACEHOLDER>` is used as a stand-in for a password of your own choosing.
Run the container image with ASP.NET Core configured for HTTPS:

Просмотреть файл

@ -107,7 +107,8 @@ public class DelayedShutdownHostLifetime : IHostLifetime, IDisposable
}
```
> Note: do not confuse `IHostLifetime` with `IHostApplicationLifetime`--they are related, but different interfaces. It is the `IHostLifetime` instance that listens for signals, including `SIGTERM`, and once a signal arrives, it calls into `IHostApplicationLifetime` instance to orchestrate application shutdown. For more information see [generic host shutdown documentation](https://learn.microsoft.com/dotnet/core/extensions/generic-host#host-shutdown)
> [!NOTE]
> Do not confuse `IHostLifetime` with `IHostApplicationLifetime`--they are related, but different interfaces. It is the `IHostLifetime` instance that listens for signals, including `SIGTERM`, and once a signal arrives, it calls into `IHostApplicationLifetime` instance to orchestrate application shutdown. For more information see [generic host shutdown documentation](https://learn.microsoft.com/dotnet/core/extensions/generic-host#host-shutdown)
Make ASP.NET use `DelayedShutdownHostLifetime` by adding it to the dependency injection container:

Просмотреть файл

@ -26,7 +26,8 @@ docker run --rm dotnetapp
The following example demonstrates how to create a private ACR Registry. Once an image is in ACR, it is easy to deploy it to ACI.
> Note: The instructions use example values that need to be changed to for your environment, specifically the password location, and the user account. More simply, make sure to change "rich" and "richlander" to something else.
> [!NOTE]
> The instructions use example values that need to be changed to for your environment, specifically the password location, and the user account. More simply, make sure to change "rich" and "richlander" to something else.
```console
az login

Просмотреть файл

@ -34,7 +34,8 @@ You need to [login to Docker Hub](https://docs.docker.com/docker-hub/accounts/)
There are a couple ways of passing a password to `docker login`. These instructions [pass the password to stdin](https://github.com/docker/cli/pull/218) via a text file called password-dh.txt. Make sure to save to a location not managed by source control (to avoid accidental disclosure).
> Note: The instructions use example values that need to be changed to for your environment, specifically the password location, and the user account. More simply, make sure to change "rich" and "richlander" to something else.
> [!NOTE]
> The instructions use example values that need to be changed to for your environment, specifically the password location, and the user account. More simply, make sure to change "rich" and "richlander" to something else.
Login on Windows:

Просмотреть файл

@ -2,7 +2,8 @@
This app demonstrates publishing an app as [native AOT](https://learn.microsoft.com/dotnet/core/deploying/native-aot/) in containers.
> Note: The base images used by this sample are in preview.
> [!NOTE]
> The base images used by this sample are in preview.
A similar console app sample supports [single file deployment](../releasesapp/README.md) (non-AOT scenario). This app could also be deployed that way.

Просмотреть файл

@ -13,7 +13,7 @@ docker build --pull -t app .
docker run --rm app
```
It will produce output similar to: https://gist.github.com/richlander/4701a33592abd021f767644974c0ced6
It will produce output similar to this [example app output](https://gist.github.com/richlander/4701a33592abd021f767644974c0ced6).
## App

Просмотреть файл

@ -36,13 +36,15 @@ You can add the element manually or use Visual Studio to do it for you. The foll
The format of the `UserSecretsId` content doesn't matter. The sample in this repo used [Random String Generator](https://www.random.org/strings/?num=6&len=20&digits=on&unique=on&format=html&rnd=new) to produce a unique string.
> Note: `User Secrets` and `Application Secrets` terms are used interchangebly.
> [!NOTE]
> `User Secrets` and `Application Secrets` terms are used interchangebly.
## Building and Running the Sample with HTTPS
Use the following instructions, for your operating system configuration. The commands assume that you are in the root of the repository.
> Note: The sample includes a banner to accept a cookie policy. When switching between HTTP and HTTPS, you may see the banner repeatedly. Delete the cookie for the site in `Developer Tools` in this case.
> [!NOTE]
> The sample includes a banner to accept a cookie policy. When switching between HTTP and HTTPS, you may see the banner repeatedly. Delete the cookie for the site in `Developer Tools` in this case.
![Developer Tools -- Delete cookie](https://user-images.githubusercontent.com/2608468/40246148-875fee5a-5a7c-11e8-9728-7da89a491014.png)
@ -65,11 +67,11 @@ dotnet dev-certs https -ep $env:USERPROFILE\.aspnet\https\aspnetapp.pfx -p <CRED
dotnet dev-certs https --trust
```
> Note: The certificate name, in this case *aspnetapp*.pfx must match the project assembly name.
> Note: `<CREDENTIAL_PLACEHOLDER>` is used as a stand-in for a password of your own choosing.
> Note: If console returns "A valid HTTPS certificate is already present.", a trusted certificate already exists in your store. It can be exported using MMC Console.
> [!NOTE]
>
> - The certificate name, in this case *aspnetapp*.pfx must match the project assembly name.
> - `<CREDENTIAL_PLACEHOLDER>` is used as a stand-in for a password of your own choosing.
> - If console returns "A valid HTTPS certificate is already present.", a trusted certificate already exists in your store. It can be exported using MMC Console.
Configure application secrets, for the certificate:
@ -78,7 +80,8 @@ dotnet user-secrets init -p aspnetapp\aspnetapp.csproj
dotnet user-secrets -p aspnetapp\aspnetapp.csproj set "Kestrel:Certificates:Development:Password" "<CREDENTIAL_PLACEHOLDER>"
```
> Note: The password must match the password used for the certificate.
> [!NOTE]
> The password must match the password used for the certificate.
Build a container image:
@ -107,9 +110,10 @@ dotnet dev-certs https -ep ${HOME}/.aspnet/https/aspnetapp.pfx -p <CREDENTIAL_PL
dotnet dev-certs https --trust
```
> Note: The certificate name, in this case *aspnetapp*.pfx must match the project assembly name.
> Note: `<CREDENTIAL_PLACEHOLDER>` is used as a stand-in for a password of your own choosing.
> [!NOTE]
>
> - The certificate name, in this case *aspnetapp*.pfx must match the project assembly name.
> - `<CREDENTIAL_PLACEHOLDER>` is used as a stand-in for a password of your own choosing.
Configure application secrets, for the certificate:
@ -118,7 +122,8 @@ dotnet user-secrets init -p aspnetapp/aspnetapp.csproj
dotnet user-secrets -p aspnetapp/aspnetapp.csproj set "Kestrel:Certificates:Development:Password" "<CREDENTIAL_PLACEHOLDER>"
```
> Note: The password must match the password used for the certificate.
> [!NOTE]
> The password must match the password used for the certificate.
Build a container image:
@ -146,11 +151,11 @@ Generate cert and configure local machine:
dotnet dev-certs https -ep ${HOME}/.aspnet/https/aspnetapp.pfx -p <CREDENTIAL_PLACEHOLDER>
```
> Note: `dotnet dev-certs https --trust` is only supported on macOS and Windows. You need to trust certs on Linux in the way that is supported by your distro. It is likely that you need to trust the certificate in your browser.
> Note: The certificate name, in this case *aspnetapp*.pfx must match the project assembly name.
> Note: `<CREDENTIAL_PLACEHOLDER>` is used as a stand-in for a password of your own choosing.
> [!NOTE]
>
> - `dotnet dev-certs https --trust` is only supported on macOS and Windows. You need to trust certs on Linux in the way that is supported by your distro. It is likely that you need to trust the certificate in your browser.
> - The certificate name, in this case *aspnetapp*.pfx must match the project assembly name.
> - `<CREDENTIAL_PLACEHOLDER>` is used as a stand-in for a password of your own choosing.
Configure application secrets, for the certificate:
@ -190,11 +195,11 @@ dotnet dev-certs https -ep $env:USERPROFILE\.aspnet\https\aspnetapp.pfx -p <CRED
dotnet dev-certs https --trust
```
> Note: The certificate name, in this case *aspnetapp*.pfx must match the project assembly name.
> Note: `<CREDENTIAL_PLACEHOLDER>` is used as a stand-in for a password of your own choosing.
> Note: If console returns "A valid HTTPS certificate is already present.", a trusted certificate already exists in your store. It can be exported using MMC Console.
> [!NOTE]
>
> - The certificate name, in this case *aspnetapp*.pfx must match the project assembly name.
> - `<CREDENTIAL_PLACEHOLDER>` is used as a stand-in for a password of your own choosing.
> - If console returns "A valid HTTPS certificate is already present.", a trusted certificate already exists in your store. It can be exported using MMC Console.
Configure application secrets, for the certificate:
@ -203,7 +208,8 @@ dotnet user-secrets init -p aspnetapp/aspnetapp.csproj
dotnet user-secrets -p aspnetapp\aspnetapp.csproj set "Kestrel:Certificates:Development:Password" "<CREDENTIAL_PLACEHOLDER>"
```
> Note: The password must match the password used for the certificate.
> [!NOTE]
> The password must match the password used for the certificate.
Build a container image:

Просмотреть файл

@ -18,7 +18,8 @@ Container scenarios that use volume mounting can produce conflicts between the `
curl -o Directory.Build.props https://raw.githubusercontent.com/dotnet/dotnet-docker/main/samples/Directory.Build.props
```
> Note: You may need to remove `bin` and `obj` directories if you run these instructions on Windows in both Windows and Linux container modes.
> [!NOTE]
> You may need to remove `bin` and `obj` directories if you run these instructions on Windows in both Windows and Linux container modes.
## Console app
@ -52,13 +53,13 @@ You can test this working by simply editing [Program.cs](dotnetapp/Program.cs).
The following instructions demonstrate this scenario in various environments.
## Linux or macOS
### Linux or macOS
```console
docker run --rm -it -v $(pwd):/app/ -w /app mcr.microsoft.com/dotnet/sdk:8.0 dotnet run
```
## Windows using Linux containers
### Windows using Linux containers
This example uses PowerShell.
@ -66,7 +67,7 @@ This example uses PowerShell.
docker run --rm -it -v ${pwd}:/app/ -w /app mcr.microsoft.com/dotnet/sdk:8.0 dotnet run
```
## Windows using Windows containers
### Windows using Windows containers
This example uses PowerShell.
@ -95,7 +96,8 @@ info: Microsoft.Hosting.Lifetime[0]
You can use CTRL-C to terminate `dotnet run`. After the application starts, navigate to `http://localhost:8000` in your web browser.
> Note: This example (and those in the instructions that follow) configure ASP.NET Core via environment variables and disable the use of a launch profile (none of the launch profiles are compatible with this scenario). Instructions are provided later in this document that add and use a new launch profile, which removes the need for specifying environment variables with the Docker CLI.
> [!NOTE]
> This example (and those in the instructions that follow) configure ASP.NET Core via environment variables and disable the use of a launch profile (none of the launch profiles are compatible with this scenario). Instructions are provided later in this document that add and use a new launch profile, which removes the need for specifying environment variables with the Docker CLI.
The following instructions demonstrate this scenario in various environments:
@ -121,7 +123,7 @@ This example uses PowerShell.
docker run --rm -it -p 8000:8080 -v ${pwd}:C:\app\ -w \app -e ASPNETCORE_HTTP_URLS=8080 -e ASPNETCORE_ENVIRONMENT=Development mcr.microsoft.com/dotnet/sdk:8.0 dotnet run --no-launch-profile
```
### Using a launch profile to configure ASP.NET Core
## Using a launch profile to configure ASP.NET Core
The examples above use environment variables to configure ASP.NET Core. You can instead [configure ASP.NET Core with a launchSettings.json file](https://docs.microsoft.com/aspnet/core/fundamentals/environments). The [launchSettings.json file](aspnetapp/aspnetapp/Properties/launchSettings.json) in this app has been updated with a `container` profile that can be used instead of specifying environment variables with the docker CLI.

Просмотреть файл

@ -22,7 +22,8 @@ Container scenarios that use volume mounting can produce conflicts between the `
curl -o Directory.Build.props https://raw.githubusercontent.com/dotnet/dotnet-docker/main/samples/Directory.Build.props
```
> Note: You may need to remove `bin` and `obj` directories if you run these instructions on Windows in both Windows and Linux container modes.
> [!NOTE]
> You may need to remove `bin` and `obj` directories if you run these instructions on Windows in both Windows and Linux container modes.
## Running tests

Просмотреть файл

@ -68,9 +68,9 @@ namespace Microsoft.DotNet.Docker.Tests
/// this helper image stores the entire root of the distroless filesystem at the specified destination path within
/// the built container image.
/// </remarks>
public string BuildDistrolessHelper(DotNetImageRepo imageRepo, ProductImageData imageData, string rootDestination)
public string BuildDistrolessHelper(DotNetImageRepo imageRepo, ProductImageData imageData, string copyDestination, string copyOrigin = "/")
{
string dockerfile = Path.Combine(TestArtifactsDir, "Dockerfile.distroless");
string dockerfile = Path.Combine(TestArtifactsDir, "Dockerfile.copy");
string distrolessImageTag = imageData.GetImage(imageRepo, this);
// Use the runtime-deps image as the target of the filesyste copy.
@ -100,9 +100,10 @@ namespace Microsoft.DotNet.Docker.Tests
platform: imageData.Platform,
buildArgs:
[
$"distroless_image={distrolessImageTag}",
$"copy_image={distrolessImageTag}",
$"base_image={baseImageTag}",
$"root_destination={rootDestination}"
$"copy_origin={copyOrigin}",
$"copy_destination={copyDestination}"
]);
return tag;

Просмотреть файл

@ -161,18 +161,6 @@ namespace Microsoft.DotNet.Docker.Tests
[MemberData(nameof(GetImageData))]
public async Task VerifyDotnetFolderContents(ProductImageData imageData)
{
// Skip test in nightly due to https://github.com/dotnet/dotnet-docker/issues/4841
if (imageData.IsWindows && Config.IsNightlyRepo)
{
return;
}
if (!IsPowerShellSupported(imageData, out string powerShellReason))
{
OutputHelper.WriteLine(powerShellReason);
return;
}
// Skip test on CBL-Mariner. Since installation is done via RPM package, we just need to verify the package installation
// was done (handled by VerifyPackageInstallation test). There's no need to check the actual contents of the package.
if (imageData.OS.StartsWith(OS.Mariner) || imageData.OS.StartsWith(OS.AzureLinux))
@ -180,11 +168,6 @@ namespace Microsoft.DotNet.Docker.Tests
return;
}
if (!imageData.SdkOS.StartsWith(OS.Alpine) && DockerHelper.IsLinuxContainerModeEnabled)
{
return;
}
IEnumerable<SdkContentFileInfo> actualDotnetFiles = GetActualSdkContents(imageData);
IEnumerable<SdkContentFileInfo> expectedDotnetFiles = await GetExpectedSdkContentsAsync(imageData);
@ -268,40 +251,57 @@ namespace Microsoft.DotNet.Docker.Tests
private IEnumerable<SdkContentFileInfo> GetActualSdkContents(ProductImageData imageData)
{
string dotnetPath;
string destinationPath;
string command;
if (DockerHelper.IsLinuxContainerModeEnabled)
{
dotnetPath = "/usr/share/dotnet";
destinationPath = "/sdk";
command = $"find {destinationPath} -type f -exec sha512sum {{}} +";
}
else
{
dotnetPath = "Program Files\\dotnet";
dotnetPath = "\"Program Files\\dotnet\"";
destinationPath = "C:\\sdk";
string powerShellCommand =
$"Get-ChildItem -File -Force -Recurse '{destinationPath}' " +
"| Get-FileHash -Algorithm SHA512 " +
"| select @{name='Value'; expression={$_.Hash + ' ' +$_.Path}} " +
"| select -ExpandProperty Value";
command = $"pwsh -Command \"{powerShellCommand}\"";
}
string powerShellCommand =
$"Get-ChildItem -File -Force -Recurse '{dotnetPath}' " +
"| Get-FileHash -Algorithm SHA512 " +
"| select @{name='Value'; expression={$_.Hash + ' ' +$_.Path}} " +
"| select -ExpandProperty Value";
string command = $"pwsh -Command \"{powerShellCommand}\"";
string baseImage = imageData.GetImage(ImageRepo, DockerHelper);
string tag = imageData.GetIdentifier("SdkContents").ToLower();
DockerHelper.Build(
tag: tag,
dockerfile: Path.Combine(DockerHelper.TestArtifactsDir, "Dockerfile.copy"),
contextDir: DockerHelper.TestArtifactsDir,
platform: imageData.Platform,
buildArgs:
[
$"copy_image={baseImage}",
$"base_image={baseImage}",
$"copy_origin={dotnetPath}",
$"copy_destination={destinationPath}"
]);
string containerFileList = DockerHelper.Run(
image: imageData.GetImage(ImageRepo, DockerHelper),
image: tag,
name: tag,
command: command,
name: imageData.GetIdentifier("DotnetFolder"),
silenceOutput: true);
IEnumerable<SdkContentFileInfo> actualDotnetFiles = containerFileList
.Replace("\r\n", "\n")
return containerFileList
.Split("\n")
.Select(output =>
.Select(line =>
{
string[] outputParts = output.Split(" ");
return new SdkContentFileInfo(outputParts[1], outputParts[0]);
string[] parts = line.Split(" ").Select(part => part.Trim()).ToArray();
return new SdkContentFileInfo(Path.GetRelativePath(destinationPath, parts[1]), parts[0]);
})
.OrderBy(fileInfo => fileInfo.Path)
.ToArray();
return actualDotnetFiles;
.OrderBy(fileInfo => fileInfo.Path);
}
private static IEnumerable<SdkContentFileInfo> EnumerateArchiveContents(string path)

Просмотреть файл

@ -0,0 +1,10 @@
ARG base_image
ARG copy_image
FROM $copy_image AS copy_image
FROM $base_image
ARG copy_origin
ARG copy_destination
COPY --from=copy_image $copy_origin $copy_destination

Просмотреть файл

@ -1,9 +0,0 @@
ARG base_image
ARG distroless_image
FROM $distroless_image AS distroless
FROM $base_image
ARG root_destination
COPY --from=distroless / $root_destination