Udostępnij za pośrednictwem


ContainerResourceBuilderExtensions.WithBuildSecret<T> Method

Definition

Adds a secret build argument when the container is built from a Dockerfile.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<T> WithBuildSecret<T> (this Aspire.Hosting.ApplicationModel.IResourceBuilder<T> builder, string name, Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ParameterResource> value) where T : Aspire.Hosting.ApplicationModel.ContainerResource;
static member WithBuildSecret : Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.ContainerResource)> * string * Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ParameterResource> -> Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.ContainerResource)> (requires 'T :> Aspire.Hosting.ApplicationModel.ContainerResource)
<Extension()>
Public Function WithBuildSecret(Of T As ContainerResource) (builder As IResourceBuilder(Of T), name As String, value As IResourceBuilder(Of ParameterResource)) As IResourceBuilder(Of T)

Type Parameters

T

The type of container resource.

Parameters

builder
IResourceBuilder<T>

The resource builder for the container resource.

name
String

The name of the secret build argument.

value
IResourceBuilder<ParameterResource>

The resource builder for a parameter resource.

Returns

The resource builder for the container resource.

Exceptions

Examples

Adding a build secret based on a parameter.

var builder = DistributedApplication.CreateBuilder(args);
var accessToken = builder.AddParameter("accessToken", secret: true);
builder.AddContainer("mycontainer", "myimage")
       .WithDockerfile("../mycontainer")
       .WithBuildSecret("ACCESS_TOKEN", accessToken);

Remarks

The WithBuildSecret<T>(IResourceBuilder<T>, String, IResourceBuilder<ParameterResource>) extension method results in a --secret argument being appended to the docker build or podman build command. This overload results in an environment variable-based secret being passed to the build process. The value of the environment variable is the value of the secret referenced by the ParameterResource.

Applies to