-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
fbfa384
Added and enabled ASP.NET Composite Images, following the messed up P…
ivdiazsa fa81417
Changed the composite suffix to match the other tags naming conventio…
ivdiazsa de07614
Added the environment variable 'DOTNET_VERSION' to the composite Dock…
ivdiazsa 9147f59
Addressed some comments. Haven't regenerated the composite Dockerfile…
ivdiazsa 1feaa43
Fake composite Dockerfiles to see if the Set-DotnetVersions script wi…
ivdiazsa 0c1ca68
Generated and added the SHA's for the Composite Dockerfiles.
ivdiazsa a431f15
Added placeholders for the composite images sizes in the ImageSize.ni…
ivdiazsa 3e39eef
Merge branch 'nightly' into containers-base
ivdiazsa 7309915
Added at least the template for the Aspnet Composite Container tests.…
ivdiazsa bf383ad
Does not work yet: Added base abstract class for Aspnet tests, both n…
ivdiazsa 183b642
Merge branch 'nightly' into containers-base
ivdiazsa 8b6d6f1
Updated Composite Dockerfiles with the most recent Nightly Branch
ivdiazsa a981e74
Undid the abstract class change because Xunit doesn't like it
ivdiazsa 202ea3e
Refactored the Aspnet and Composite tests using a new approach.
ivdiazsa c6e83af
Merge branch 'nightly' into containers-base
ivdiazsa 3960705
Merge branch 'nightly' into containers-base
ivdiazsa 02a8a3e
Addressed given feedback.
ivdiazsa b77d178
Accommodate aspnet and composite versions side-by-side in update-depe…
lbussell be696df
Added 'aspnet-composite' to the main 'run-tests.ps1' script
ivdiazsa c3133e2
Merge branch 'nightly' into containers-base
ivdiazsa c70c886
Fixed merge conflict on README.aspnet.md
ivdiazsa 158eb7a
Sigh now versions changed
ivdiazsa 43ae096
Shas...
ivdiazsa b20f87a
Add real image sizes
lbussell 99ee0ed
Added composite containers documentation.
ivdiazsa 51f7e31
Rephrased and moved composites doc
ivdiazsa 5eabb6c
Made composites a subsection of About
ivdiazsa 321434a
Flow top-header to the composite sub-template
ivdiazsa d385abd
Templates were wrong
ivdiazsa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
eng/dockerfile-templates/aspnet/Dockerfile.linux-composite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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")}}}}}} | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| This image contains the ASP.NET Core and .NET runtimes and libraries and is optimized for running ASP.NET Core apps in production. | ||
|
|
||
| {{InsertTemplate("About.composite-aspnet.md", [ "top-header": ARGS["top-header"] ])}} | ||
ivdiazsa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| {{ | ||
| _ ARGS: | ||
| top-header: The string to use as the top-level header. | ||
| readme-host: Moniker of the site that will host the readme | ||
| }}{{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). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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
Aboutsection of README.aspnet.md comes from https://github.com/dotnet/dotnet-docker/blob/nightly/eng/readme-templates/About.aspnet.md. Readmes can be regenerated from templates by runningeng\readme-templates\Get-GeneratedReadmes.ps1There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mthalman - we have a technical description of the composite format here:
https://github.com/dotnet/runtime/blob/main/docs/design/features/readytorun-composite-format-design.md
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.