Skip to content

IResourceContainerImageBuilder doesn't support BuildArguments and BuildSecrets #8770

@eerhardt

Description

@eerhardt

When calling IResourceContainerImageBuilder.BuildImageAsync:

public interface IResourceContainerImageBuilder
{
/// <summary>
/// Builds a container that represents the specified resource.
/// </summary>
/// <param name="resource">The resource to build.</param>
/// <param name="cancellationToken">The cancellation token.</param>
Task BuildImageAsync(IResource resource, CancellationToken cancellationToken);
}

There is no logic for resolving BuildArguments and BuildSecrets on the DockerfileBuildAnnotation.

/// <summary>
/// Gets the arguments to pass to the build.
/// </summary>
public Dictionary<string, object?> BuildArguments { get; } = [];
/// <summary>
/// Gets the secrets to pass to the build.
/// </summary>
public Dictionary<string, object> BuildSecrets { get; } = [];

Same for the Stage property.

Repro steps:

var builder = DistributedApplication.CreateBuilder(args);

var goVersion = builder.AddParameter("goversion", "1.22");
var secret = builder.AddParameter("secret", secret: true);

builder.AddDockerfile("mycontainer", "qots")
       .WithBuildArg("GO_VERSION", goVersion)
       .WithBuildSecret("SECRET_ASENV", secret);
# Stage 1: Build the Go program
ARG GO_VERSION=1.23
FROM mcr.microsoft.com/oss/go/microsoft/golang:${GO_VERSION} AS builder
WORKDIR /app
COPY . .
RUN go build qots.go

# Stage 2: Run the Go program
FROM mcr.microsoft.com/cbl-mariner/base/core:2.0
WORKDIR /app
RUN --mount=type=secret,id=SECRET_ASENV cp /run/secrets/SECRET_ASENV /app/SECRET_ASENV
COPY --from=builder /app/qots .
CMD ["./qots"]

Call BuildImageAsync on the above resource. It should respect the build arg and build secret.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions