DockerfileBuilder Methods
ClassMethods5 members
Builder for creating Dockerfiles programmatically.
Adds a global ARG statement to define a build-time variable before any stages.
public class DockerfileBuilder{ public DockerfileBuilder Arg( string name) { // ... }}Parameters
namestringThe name of the build argument.Returns
DockerfileBuilder The current DockerfileBuilder instance for method chaining.Remarks
Global ARG statements appear before the first FROM statement and can be used to parameterize the base image selection.
Adds a global ARG statement to define a build-time variable with a default value before any stages.
public class DockerfileBuilder{ public DockerfileBuilder Arg( string name, string defaultValue) { // ... }}Parameters
namestringThe name of the build argument.defaultValue stringThe default value for the build argument.Returns
DockerfileBuilder The current DockerfileBuilder instance for method chaining.Remarks
Global ARG statements appear before the first FROM statement and can be used to parameterize the base image selection.
Adds a FROM statement to start a new named stage.
public class DockerfileBuilder{ public DockerfileStage From( string image, string stageName) { // ... }}Parameters
imagestringThe image reference (e.g., 'node:18' or 'alpine:latest').stageName stringThe stage name for multi-stage builds.Returns
DockerfileStage A stage builder for the new stage. Adds a FROM statement to start a new stage.
public class DockerfileBuilder{ public DockerfileStage From( string image) { // ... }}Parameters
imagestringThe image reference (e.g., 'node:18' or 'alpine:latest').Returns
DockerfileStage A stage builder for the new stage.WriteAsync(StreamWriter, CancellationToken) Section titled WriteAsync(StreamWriter, CancellationToken)Task Writes the Dockerfile content to the specified
IO.StreamWriter . public class DockerfileBuilder{ public Task WriteAsync( StreamWriter writer, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
writerStreamWriter The IO.StreamWriter to write to.cancellationToken CancellationToken optionalA cancellation token.Returns
TaskA task representing the asynchronous write operation.