Share via


DockerfileFactoryContext Class

Definition

Provides context for Dockerfile factory functions.

public sealed class DockerfileFactoryContext
type DockerfileFactoryContext = class
Public NotInheritable Class DockerfileFactoryContext
Inheritance
DockerfileFactoryContext

Constructors

DockerfileFactoryContext()

Properties

CancellationToken

Gets the cancellation token for the operation.

Resource

Gets the resource for which the Dockerfile is being generated.

This allows factory functions to query resource annotations and properties to customize the generated Dockerfile.

<example>
var containerAnnotation = context.Resource.Annotations.OfType<ContainerImageAnnotation>().FirstOrDefault();
var baseImage = containerAnnotation?.Image ?? "alpine:latest";
</example>
Services

Gets the IServiceProvider for resolving dependencies required by Dockerfile factory functions.

The service provider typically contains services such as IHostEnvironment, ILogger, and configuration objects relevant to the application model. Factory functions can use this provider to obtain required services for generating Dockerfiles.

<example>
var logger = context.Services.GetRequiredService<ILogger>();
</example>

Applies to