Skip to content
Docs Try Aspire

ContainerFilesExtensions Methods

Class Methods 2 members
Provides Dockerfile builder extension methods for supporting ResourceBuilderExtensions.PublishWithContainerFiles.
AddContainerFiles(DockerfileStage, IResource, string, ILogger?) Section titled AddContainerFiles(DockerfileStage, IResource, string, ILogger?) extension DockerfileStage
Adds COPY --from statements to the Dockerfile stage for container files from resources referenced by ContainerFilesDestinationAnnotation.
public static class ContainerFilesExtensions
{
public static DockerfileStage AddContainerFiles(
this DockerfileStage stage,
IResource resource,
string rootDestinationPath,
ILogger? logger)
{
// ...
}
}
stage DockerfileStage The Dockerfile stage to add container file copy statements to.
resource IResource The resource that may have ContainerFilesDestinationAnnotation annotations specifying files to copy.
rootDestinationPath string The root destination path in the container. Relative paths in annotations will be appended to this path.
logger ILogger? The logger used for logging information or errors.
DockerfileStage The DockerfileStage to allow for fluent chaining.

This method processes all ContainerFilesDestinationAnnotation annotations on the resource and generates COPY --from statements for each source container's files.

For each annotation:

This is typically used when building container images that need to include files from other containers, such as copying static assets from a frontend build container into a backend API container.

AddContainerFilesStages(DockerfileBuilder, IResource, ILogger?) Section titled AddContainerFilesStages(DockerfileBuilder, IResource, ILogger?) extension DockerfileBuilder
Adds Dockerfile instructions to include container files from the specified resource into the Dockerfile build process.
public static class ContainerFilesExtensions
{
public static DockerfileBuilder AddContainerFilesStages(
this DockerfileBuilder builder,
IResource resource,
ILogger? logger)
{
// ...
}
}
builder DockerfileBuilder The Dockerfile builder to which container file instructions will be added. Cannot be null.
resource IResource The resource containing container files to be added to the Dockerfile. Cannot be null.
logger ILogger? An optional logger used to record warnings if container image names cannot be determined for source resources.
DockerfileBuilder The same DockerfileBuilder instance with additional instructions for container files, enabling method chaining.