-
Notifications
You must be signed in to change notification settings - Fork 2k
[Fixed] - Add Dockerfiles for Linux .NET Composite Images #4594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 26 commits
fbfa384
fa81417
de07614
9147f59
1feaa43
0c1ca68
a431f15
3e39eef
7309915
bf383ad
183b642
8b6d6f1
a981e74
202ea3e
c6e83af
3960705
02a8a3e
b77d178
be696df
c3133e2
c70c886
158eb7a
43ae096
b20f87a
99ee0ed
51f7e31
5eabb6c
321434a
d385abd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should really have some sort of documentation that describes the purpose of these composite images (i.e. what are they? how do they differ from the regular aspnet images? how do I determine which one to use?). If necessary, this can link to another doc page that describes things in more detail. Note that the Docker repository readmes are generated from templates. For example, the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mthalman - we have a technical description of the composite format here: In terms of our current shipping story the composite container is a tool a customer can use to reduce container size on disk while keeping performance of default R2R publishing with the caveat that the composite container has tighter version coupling - in particular, the final app is not allowed to use handpicked custom versions of framework / ASP.NET assemblies that are baked into the composite image. @ivdiazsa - please let me know if you need further help with the actual wording. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,6 +17,12 @@ | |||||
|
|
||||||
| This image contains the ASP.NET Core and .NET runtimes and libraries and is optimized for running ASP.NET Core apps in production. | ||||||
|
|
||||||
| # Composite container images | ||||||
|
||||||
| # Composite container images | |
| ## Composite container images |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| {{ | ||
| set dotnetVersion to join(slice(split(PRODUCT_VERSION, "."), 0, 2), ".") ^ | ||
| set isAlpine to find(OS_VERSION, "alpine") >= 0 ^ | ||
| set isMariner to find(OS_VERSION, "mariner") >= 0 ^ | ||
| set isDistroless to find(OS_VERSION, "distroless") >= 0 || find(OS_VERSION, "chiseled") >= 0 ^ | ||
| set isFullMariner to isMariner && !isDistroless ^ | ||
| set isDistrolessMariner to isMariner && isDistroless ^ | ||
| set baseUrl to VARIABLES[cat("base-url|", dotnetVersion, "|", VARIABLES["branch"])] ^ | ||
| set isInternal to find(baseUrl, "msrc") >= 0 || find(baseUrl, "internal") >= 0 ^ | ||
| set isRpmInstall to false ^ | ||
| set isSingleStage to (isAlpine || isRpmInstall) && !isInternal ^ | ||
| set runtimeDepsBaseTag to | ||
| cat("$REPO:", VARIABLES[cat("dotnet|", dotnetVersion, "|product-version")], "-", OS_VERSION, ARCH_TAG_SUFFIX) ^ | ||
| set osVersionBase to when(isDistroless, match(OS_VERSION, ".+(?=.*-)")[0], OS_VERSION_BASE) ^ | ||
| set installerImageTag to when(isDistrolessMariner, | ||
| cat("mcr.microsoft.com/cbl-mariner/base/core:", OS_VERSION_NUMBER), | ||
| when(isAlpine || isFullMariner, | ||
| runtimeDepsBaseTag, | ||
| cat(ARCH_VERSIONED, "/buildpack-deps:", osVersionBase, "-curl"))) | ||
| }}ARG REPO=mcr.microsoft.com/dotnet/runtime-deps{{ if isSingleStage: | ||
| {{ | ||
|
|
||
| _ SINGLE STAGE | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would just like to note that there are unused options in this file but we should leave them for if we decide to ship non-musl variants of composite images in the future. |
||
|
|
||
| }}FROM {{runtimeDepsBaseTag}} | ||
| {{ if isAlpine: | ||
| {{InsertTemplate("../Dockerfile.alpine.invariant-mode")}} | ||
| }} | ||
| {{InsertTemplate("../runtime/Dockerfile.envs")}} | ||
| {{InsertTemplate("Dockerfile.envs")}} | ||
|
|
||
| # Install ASP.NET Composite Runtime | ||
| {{InsertTemplate("../runtime/Dockerfile.linux.install-runtime", | ||
| [ | ||
| "install-method": "download-and-install", | ||
| "dest-dir": "/usr/share/dotnet", | ||
| "add-symlink": !isRpmInstall, | ||
| "is-rpm-install": isRpmInstall, | ||
| "is-composite-runtime": "true", | ||
| ])}}^ | ||
| else:{{ | ||
|
|
||
| _ MULTI STAGE | ||
|
|
||
| }} | ||
|
|
||
| # Installer image | ||
| FROM {{installerImageTag}} AS installer | ||
| {{ if isInternal: | ||
| ARG SAS_QUERY_STRING | ||
| }}{{ if isDistrolessMariner: | ||
| {{InsertTemplate("../Dockerfile.linux.distroless-mariner-installer-prereqs")}} | ||
| ^elif isFullMariner && !isRpmInstall: | ||
| RUN {{InsertTemplate("../Dockerfile.linux.install-pkgs", | ||
| [ | ||
| "pkgs": ["tar"] | ||
| ])}} | ||
| }} | ||
|
|
||
| # Retrieve ASP.NET Composite Runtime | ||
| {{InsertTemplate("../runtime/Dockerfile.linux.install-runtime", | ||
| [ | ||
| "install-method": when(isInternal && isRpmInstall, "download", "download-and-install"), | ||
| "use-local-version-var": "true", | ||
| "dest-dir": when(isDistroless, "/usr/share/dotnet", "/dotnet"), | ||
| "is-internal": isInternal, | ||
| "url-suffix": when(isInternal, "$SAS_QUERY_STRING", ""), | ||
| "is-rpm-install": isRpmInstall, | ||
| "is-composite-runtime": "true" | ||
| ])}}{{ if isDistroless: | ||
|
|
||
| RUN mkdir /dotnet-symlink \ | ||
| && ln -s /usr/share/dotnet/dotnet /dotnet-symlink/dotnet}} | ||
|
|
||
| # ASP.NET Composite Runtime Image | ||
| FROM {{runtimeDepsBaseTag}} | ||
|
|
||
| {{InsertTemplate("../runtime/Dockerfile.envs")}} | ||
| {{InsertTemplate("Dockerfile.envs")}} | ||
| {{ if isInternal && isRpmInstall: | ||
| {{InsertTemplate("Dockerfile.linux.install-runtime", | ||
| [ | ||
| "install-method": "copy-and-install", | ||
| "dest-dir": when(isDistroless, "/usr/share/dotnet", "/dotnet"), | ||
| "is-internal": isInternal, | ||
| "url-suffix": when(isInternal, "$SAS_QUERY_STRING", ""), | ||
| "installer-stage": "installer", | ||
| "is-rpm-install": isRpmInstall | ||
| ])}}}}{{ if isDistroless: | ||
| COPY --from=installer ["/usr/share/dotnet", "/usr/share/dotnet"] | ||
| COPY --from=installer ["/dotnet-symlink", "/usr/bin"]{{ if !isMariner || dotnetVersion != "6.0": | ||
|
|
||
| ENTRYPOINT ["/usr/bin/dotnet"] | ||
| CMD ["--info"]}}^ | ||
| elif !(isInternal && isRpmInstall): | ||
| COPY --from=installer ["/dotnet", "/usr/share/dotnet"] | ||
| RUN {{InsertTemplate("../runtime/Dockerfile.linux.symlink")}}}}}} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,7 @@ | ||
| This image contains the ASP.NET Core and .NET runtimes and libraries and is optimized for running ASP.NET Core apps in production. | ||
|
|
||
| {{ARGS["top-header"]}}# Composite container images | ||
|
|
||
| Starting from .NET 8, a composite version of the ASP.NET images, `denoted with the -composite` tag part, is being offered alongside the regular image. The main characteristics of these images are their 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). |
Uh oh!
There was an error while loading. Please reload this page.