ContainerFilesExtensions Methods
ResourceBuilderExtensions.PublishWithContainerFiles. AddContainerFiles(DockerfileStage, IResource, string, ILogger?)Section titled AddContainerFiles(DockerfileStage, IResource, string, ILogger?)extensionDockerfileStageContainerFilesDestinationAnnotation. public static class ContainerFilesExtensions{ public static DockerfileStage AddContainerFiles( this DockerfileStage stage, IResource resource, string rootDestinationPath, ILogger? logger) { // ... }}Parameters
stageDockerfileStageThe Dockerfile stage to add container file copy statements to.resourceIResourceThe resource that may have ContainerFilesDestinationAnnotation annotations specifying files to copy.rootDestinationPathstringThe root destination path in the container. Relative paths in annotations will be appended to this path.loggerILogger?The logger used for logging information or errors.Returns
DockerfileStageThe DockerfileStage to allow for fluent chaining.Remarks
This method processes all ContainerFilesDestinationAnnotation annotations on the resource and generates COPY --from statements for each source container's files.
For each annotation: TryGetContainerImageName), COPY statements are generatedrootDestinationPathContainerFilesSourceAnnotation on the source resource generates a COPY statement
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?)extensionDockerfileBuilderpublic static class ContainerFilesExtensions{ public static DockerfileBuilder AddContainerFilesStages( this DockerfileBuilder builder, IResource resource, ILogger? logger) { // ... }}Parameters
builderDockerfileBuilderThe Dockerfile builder to which container file instructions will be added. Cannot be null.resourceIResourceThe resource containing container files to be added to the Dockerfile. Cannot be null.loggerILogger?An optional logger used to record warnings if container image names cannot be determined for source resources.Returns
DockerfileBuilderThe same DockerfileBuilder instance with additional instructions for container files, enabling method chaining.