# addDockerfileFactory

- Module: [Aspire.Hosting](/reference/api/typescript/aspire.hosting.md)
- Version: `13.4.0`
- Kind: `method`
- Source: [GitHub](https://github.com/microsoft/aspire)

Adds a Dockerfile to the application model that can be treated like a container resource, with the Dockerfile content generated by an asynchronous factory function.

## Definition

```typescript
interface IDistributedApplicationBuilder {
  // ... omitted for brevity
  addDockerfileFactory(name: string, contextPath: string, dockerfileFactory: (arg: DockerfileFactoryContext) => Promise<string>, stage?: string): ContainerResource
}
```

## Parameters

- `name` (`string`)
- `contextPath` (`string`)
- `dockerfileFactory` (`(arg: DockerfileFactoryContext) => Promise<string>`)
- `stage` (`string`) `optional`

## Returns

[ContainerResource](/reference/api/typescript/aspire.hosting/containerresource.md) `builder`

## Applies to

- [IDistributedApplicationBuilder](/reference/api/typescript/aspire.hosting/idistributedapplicationbuilder.md)
