|
| 1 | +# ASP.NET Core Runtime 6.0 container image |
| 2 | + |
| 3 | +[-Build_L3-Green)](https://documentation.suse.com/sbp/server-linux/html/SBP-SLSA4/) |
| 4 | +[](https://documentation.suse.com/container/all/html/Container-guide/index.html#container-verify) |
| 5 | + |
| 6 | +## Description |
| 7 | + |
| 8 | +.NET is a general purpose development platform. |
| 9 | +It is cross-platform, and can be used in devices, cloud, and embedded/IoT scenarios. |
| 10 | +You can use C# or F# to write .NET applications. |
| 11 | + |
| 12 | +This image contains the ASP.NET Core and .NET runtimes and libraries, |
| 13 | +and it is optimized for running ASP.NET Core applications in production. |
| 14 | + |
| 15 | +## Notice |
| 16 | + |
| 17 | +The .NET packages in the image come from a third-party repository |
| 18 | +[packages.microsoft.com](https://packages.microsoft.com). |
| 19 | + |
| 20 | +The source code is available on [github.com/dotnet](https://github.com/dotnet). |
| 21 | + |
| 22 | +SUSE does not provide any support or warranties for the third-party components in the image. |
| 23 | + |
| 24 | +## Usage |
| 25 | + |
| 26 | +To compile and deploy an application, copy the sources and build the binary: |
| 27 | + |
| 28 | +```Dockerfile |
| 29 | +FROM registry.suse.com/bci/dotnet-sdk:6.0 AS build |
| 30 | +WORKDIR /source |
| 31 | + |
| 32 | +# copy csproj and restore as distinct layers |
| 33 | +COPY aspnetapp/*.csproj . |
| 34 | +RUN dotnet restore |
| 35 | + |
| 36 | +# copy and publish app and libraries |
| 37 | +COPY aspnetapp/. . |
| 38 | +RUN dotnet publish --no-restore -o /app |
| 39 | + |
| 40 | +# final image |
| 41 | +FROM registry.suse.com/bci/dotnet-aspnet:6.0 |
| 42 | + |
| 43 | +WORKDIR /app |
| 44 | +COPY --from=build /app . |
| 45 | + |
| 46 | +EXPOSE 8080 |
| 47 | + |
| 48 | +# uncomment to run as non-root user |
| 49 | +# USER $APP_UID |
| 50 | + |
| 51 | +ENTRYPOINT ["./aspnetapp"] |
| 52 | +``` |
| 53 | + |
| 54 | +Build and run the container image: |
| 55 | + |
| 56 | +```ShellSession |
| 57 | +podman build -t my-aspnet-app . |
| 58 | +podman run -it --rm -p 8080:8080 my-aspnet-app |
| 59 | +``` |
| 60 | + |
| 61 | +## HTTPS and certificates |
| 62 | + |
| 63 | +ASP.NET Core uses [HTTPS by default](https://docs.microsoft.com/aspnet/core/security/enforcing-ssl). |
| 64 | +You need a valid certificate for production deployments. |
| 65 | + |
| 66 | +To create a self-signed certificate for testing, use the following command: |
| 67 | + |
| 68 | +```ShellSession |
| 69 | +podman run --rm -it -v "$PWD/https":/https:Z \ |
| 70 | + registry.suse.com/bci/dotnet-sdk:6.0 \ |
| 71 | + dotnet dev-certs https -ep /https/aspnetapp.pfx -p <PASSWORD> |
| 72 | +``` |
| 73 | + |
| 74 | +To use a certificate and run the container image with ASP.NET Core configured for HTTPS in development or production, use the following command: |
| 75 | + |
| 76 | +```ShellSession |
| 77 | +podman run --rm -it -p 8081:8081 \ |
| 78 | + -e ASPNETCORE_HTTPS_PORTS=8081 \ |
| 79 | + -e ASPNETCORE_Kestrel__Certificates__Default__Password="<PASSWORD>" \ |
| 80 | + -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx \ |
| 81 | + -v "$PWD/https":/https:Z my-apsnet-app |
| 82 | +``` |
| 83 | + |
| 84 | +## Globalization |
| 85 | + |
| 86 | +.NET includes [globalization](https://learn.microsoft.com/dotnet/core/extensions/globalization-and-localization) capabilities, including support for processing natural language text, calendars, currency, and timezones. The .NET implementation for these capabilities is based on system libraries available in the container image, such as [International Components for Unicode (ICU)](https://icu.unicode.org/) and [tzdata](https://wikipedia.org/wiki/Tz_database). |
| 87 | + |
| 88 | +It's considered a good practice to pass timezone information into a container via environment variable `TZ`. |
| 89 | + |
| 90 | +```bash |
| 91 | +podman run --rm -it -e TZ="Europe/Berlin" app |
| 92 | +``` |
| 93 | + |
| 94 | +## Licensing |
| 95 | + |
| 96 | +`SPDX-License-Identifier: MIT` |
| 97 | + |
| 98 | +This documentation and the build recipe are licensed as MIT. |
| 99 | +The container itself contains various software components under various open source licenses listed in the associated |
| 100 | +Software Bill of Materials (SBOM). |
| 101 | + |
| 102 | +This image is a tech preview. Do not use it for production. |
| 103 | +Your feedback is welcome. |
| 104 | +Please report any issues to the [SUSE Bugzilla](https://bugzilla.suse.com/enter_bug.cgi?product=SUSE%20Linux%20Enterprise%20Base%20Container%20Images). |
0 commit comments