DockerfileStage Methods
Class Methods 17 members
Represents a stage within a multi-stage Dockerfile.
Adds an ARG statement to define a build-time variable.
public class DockerfileStage{ public DockerfileStage Arg( string name) { // ... }}Parameters
name string The name of the build argument. Returns
DockerfileStage The current stage. Adds an ARG statement to define a build-time variable with a default value.
public class DockerfileStage{ public DockerfileStage Arg( string name, string defaultValue) { // ... }}Parameters
name string The name of the build argument. defaultValue string The default value for the build argument. Returns
DockerfileStage The current stage. Adds a CMD statement to set the default command.
public class DockerfileStage{ public DockerfileStage Cmd( string[] command) { // ... }}Parameters
command string[] The command to execute. Returns
DockerfileStage The current stage. Adds a comment to the Dockerfile. Multi-line comments are supported.
public class DockerfileStage{ public DockerfileStage Comment( string comment) { // ... }}Parameters
comment string The comment text. Can be single-line or multi-line. Returns
DockerfileStage The current stage. Remarks
When a multi-line comment is provided, each line will be prefixed with '#'. Empty lines in multi-line comments are preserved as comment lines.
Adds a COPY statement to copy files from the build context.
public class DockerfileStage{ public DockerfileStage Copy( string source, string destination) { // ... }}Parameters
source string The source path or pattern. destination string The destination path. Returns
DockerfileStage The current stage. Adds a COPY statement to copy files with ownership change.
public class DockerfileStage{ public DockerfileStage Copy( string source, string destination, string chown) { // ... }}Parameters
source string The source path. destination string The destination path. chown string The ownership specification (e.g., "user:group"). Returns
DockerfileStage The current stage. Adds a COPY statement to copy files from another stage.
public class DockerfileStage{ public DockerfileStage CopyFrom( string from, string source, string destination) { // ... }}Parameters
from string The source stage or image name. source string The source path in the stage. destination string The destination path. Returns
DockerfileStage The current stage. CopyFrom(string, string, string, string) Section titled CopyFrom(string, string, string, string) DockerfileStage Adds a COPY statement to copy files from another stage with ownership change.
public class DockerfileStage{ public DockerfileStage CopyFrom( string stage, string source, string destination, string chown) { // ... }}Parameters
stage string The source stage name. source string The source path in the stage. destination string The destination path. chown string The ownership specification (e.g., "user:group"). Returns
DockerfileStage The current stage. Adds an empty line to the Dockerfile for better readability.
public class DockerfileStage{ public DockerfileStage EmptyLine() { // ... }}Returns
DockerfileStage The current stage. Adds an ENTRYPOINT statement to set the container entrypoint.
public class DockerfileStage{ public DockerfileStage Entrypoint( string[] command) { // ... }}Parameters
command string[] The entrypoint command to execute. Returns
DockerfileStage The current stage. Adds an ENV statement to set an environment variable.
public class DockerfileStage{ public DockerfileStage Env( string name, string value) { // ... }}Parameters
name string The environment variable name. value string The environment variable value. Returns
DockerfileStage The current stage. Adds an EXPOSE statement to expose a port.
public class DockerfileStage{ public DockerfileStage Expose( int port) { // ... }}Parameters
port int The port number to expose. Returns
DockerfileStage The current stage. Adds a RUN statement to execute a command.
public class DockerfileStage{ public DockerfileStage Run( string command) { // ... }}Parameters
command string The command to execute. Returns
DockerfileStage The current stage. Adds a RUN statement with mount options for BuildKit.
public class DockerfileStage{ public DockerfileStage RunWithMounts( string command, params string[] mounts) { // ... }}Parameters
command string The command to execute. mounts string[] The mount options (e.g., "type=cache,target=/root/.cache"). Returns
DockerfileStage The current stage. Adds a USER statement to set the user for subsequent commands.
public class DockerfileStage{ public DockerfileStage User( string user) { // ... }}Parameters
user string The user name or UID. Returns
DockerfileStage The current stage. Adds a WORKDIR statement to set the working directory.
public class DockerfileStage{ public DockerfileStage WorkDir( string path) { // ... }}Parameters
path string The working directory path. Returns
DockerfileStage The current stage. WriteStatementAsync(StreamWriter, CancellationToken) Section titled WriteStatementAsync(StreamWriter, CancellationToken) override Task Writes the statement to the specified writer.
public class DockerfileStage{ public override Task WriteStatementAsync( StreamWriter writer, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
writer StreamWriter The writer to write to. cancellationToken CancellationToken optional A cancellation token. Returns
Task A task representing the asynchronous write operation.