Skip to content

Allow docker build secrets to be files#14559

Merged
eerhardt merged 2 commits intodotnet:release/13.2from
eerhardt:FixBuildSecrets
Feb 19, 2026
Merged

Allow docker build secrets to be files#14559
eerhardt merged 2 commits intodotnet:release/13.2from
eerhardt:FixBuildSecrets

Conversation

@eerhardt
Copy link
Member

@eerhardt eerhardt commented Feb 19, 2026

Description

This allows people to pass .npmrc files as docker secrets without baking auth credentials into this image.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

This allows people to pass .npmrc files as docker secrets without baking auth credentials into this image.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14559

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14559"

@mitchdenny
Copy link
Member

Do you think we should have `WithBuildSecretFile(callback) where we can give it a file, but defer evaluation.

@dotnet-policy-service dotnet-policy-service bot added the needs-author-action An issue or pull request that requires more info or actions from the author. label Feb 19, 2026
@eerhardt eerhardt requested a review from karolz-ms February 19, 2026 21:12
@dotnet-policy-service dotnet-policy-service bot removed the needs-author-action An issue or pull request that requires more info or actions from the author. label Feb 19, 2026
@mitchdenny mitchdenny marked this pull request as ready for review February 19, 2026 22:25
Copilot AI review requested due to automatic review settings February 19, 2026 22:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 BuildImageSecretValue record and BuildImageSecretType enum to represent both environment-based and file-based secrets
  • Updates IContainerRuntime.BuildImageAsync signature to use Dictionary<string, BuildImageSecretValue> instead of Dictionary<string, string?>
  • Modifies secret resolution logic in ResourceContainerImageManager to detect FileInfo objects and mark them as file-based secrets
  • Updates BuildSecretsString method 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

@eerhardt eerhardt enabled auto-merge (squash) February 19, 2026 23:46
@eerhardt eerhardt merged commit f3d3d63 into dotnet:release/13.2 Feb 19, 2026
680 of 684 checks passed
@eerhardt eerhardt deleted the FixBuildSecrets branch February 19, 2026 23:57
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants