Allow docker build secrets to be files#14559
Merged
eerhardt merged 2 commits intodotnet:release/13.2from Feb 19, 2026
Merged
Conversation
This allows people to pass .npmrc files as docker secrets without baking auth credentials into this image.
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14559Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14559" |
Member
|
Do you think we should have `WithBuildSecretFile(callback) where we can give it a file, but defer evaluation. |
karolz-ms
requested changes
Feb 19, 2026
karolz-ms
approved these changes
Feb 19, 2026
mitchdenny
approved these changes
Feb 19, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds support for file-based Docker build secrets in addition to the existing environment variable-based secrets. This allows developers to pass files like .npmrc as build secrets without embedding authentication credentials directly in container images.
Changes:
- Introduces
BuildImageSecretValuerecord andBuildImageSecretTypeenum to represent both environment-based and file-based secrets - Updates
IContainerRuntime.BuildImageAsyncsignature to useDictionary<string, BuildImageSecretValue>instead ofDictionary<string, string?> - Modifies secret resolution logic in
ResourceContainerImageManagerto detect FileInfo objects and mark them as file-based secrets - Updates
BuildSecretsStringmethod to format secrets appropriately based on type (env vs file) - Adds comprehensive test coverage for the new functionality
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Aspire.Hosting/Publishing/BuildImageSecretValue.cs | New file defining the BuildImageSecretValue record and BuildImageSecretType enum marked as Experimental |
| src/Aspire.Hosting/Publishing/ResourceContainerImageManager.cs | Updates secret resolution to detect FileInfo and create BuildImageSecretValue with appropriate type |
| src/Aspire.Hosting/Publishing/ContainerRuntimeBase.cs | Modifies BuildSecretsString to format secrets based on type (file uses src=path, env uses env=VAR) |
| src/Aspire.Hosting/Publishing/DockerContainerRuntime.cs | Updates to use BuildImageSecretValue and only set environment variables for environment-type secrets |
| src/Aspire.Hosting/Publishing/PodmanContainerRuntime.cs | Updates to use BuildImageSecretValue and only set environment variables for environment-type secrets |
| src/Aspire.Hosting/Publishing/IContainerRuntime.cs | Updates BuildImageAsync signature to accept Dictionary<string, BuildImageSecretValue> |
| tests/Aspire.Hosting.Tests/Publishing/FakeContainerRuntime.cs | Updates test fake to use BuildImageSecretValue type |
| tests/Aspire.Hosting.Tests/Publishing/ResourceContainerImageManagerTests.cs | Adds comprehensive tests for file-based secrets and updates existing tests to verify both Value and Type properties |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This allows people to pass .npmrc files as docker secrets without baking auth credentials into this image.
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: