# AddDockerfile

- Module: [Aspire.Hosting](/reference/api/go/aspire.hosting.md)
- Version: `17.0.0`
- Kind: `method`
- Defined on: [`DistributedApplicationBuilder`](/reference/api/go/aspire.hosting/distributedapplicationbuilder.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

Adds a Dockerfile to the application model that can be treated like a container resource.

## Definition

```go
func (DistributedApplicationBuilder) AddDockerfile(
    name string,
    contextPath string,
    options ...*AddDockerfileOptions,
) ContainerResource
```

## Parameters

- `name` (`string`) -- The name of the resource.
- `contextPath` (`string`) -- Path to be used as the context for the container image build.
- `options` (`...*AddDockerfileOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed in a trailing `options ...*AddDockerfileOptions` argument.

- `DockerfilePath` (`*string`) -- Path to the Dockerfile relative to the `contextPath`. Defaults to "Dockerfile" if not specified.
- `Stage` (`*string`) -- The stage representing the image to be published in a multi-stage Dockerfile.

## Returns

[`ContainerResource`](/reference/api/go/aspire.hosting/containerresource.md) -- The resource builder.

Returns a handle; failures surface later via `Err()`.

## Applies to

- [`DistributedApplicationBuilder`](/reference/api/go/aspire.hosting/distributedapplicationbuilder.md)
