# IDistributedApplicationBuilder.addDockerfileFactory

- Module: [Aspire.Hosting](/reference/api/typescript/aspire.hosting.md)
- Defined on: [IDistributedApplicationBuilder](/reference/api/typescript/aspire.hosting/idistributedapplicationbuilder.md)
- Version: `13.4.0`
- Kind: `method`

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;
}
```

## Signature

```typescript
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`

## Defined on

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