> **Experimental**
>
> `@aws-cdk/aws-imagebuilder-alpha` is an [**experimental**](https://docs.aws.amazon.com/cdk/api/stability.html) (alpha) package: its API may change in any release, without a major version bump.
# DockerfileData

Helper class for referencing and uploading dockerfile data for the container recipe.

Superclass of: [S3DockerfileData](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-imagebuilder-alpha.S3DockerfileData.html)
Obtainable from: DockerfileData.fromInline

- Stability: [Experimental](https://docs.aws.amazon.com/cdk/api/stability.html)
- Source: [`lib/container-recipe.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/@aws-cdk/aws-imagebuilder-alpha/lib/container-recipe.ts#L191)

## Example

TypeScript:

```ts
const containerRecipe = new imagebuilder.ContainerRecipe(this, 'CustomDockerfileContainerRecipe', {
  baseImage: imagebuilder.BaseContainerImage.fromDockerHub('amazonlinux', 'latest'),
  targetRepository: imagebuilder.Repository.fromEcr(
    ecr.Repository.fromRepositoryName(this, 'Repository', 'my-container-repo')
  ),
  dockerfile: imagebuilder.DockerfileData.fromInline(`
FROM {{{ imagebuilder:parentImage }}}
CMD ["echo", "Hello, world!"]
{{{ imagebuilder:environments }}}
{{{ imagebuilder:components }}}
`)
});
```

Python:

```python
container_recipe = imagebuilder.ContainerRecipe(self, "CustomDockerfileContainerRecipe",
    base_image=imagebuilder.BaseContainerImage.from_docker_hub("amazonlinux", "latest"),
    target_repository=imagebuilder.Repository.from_ecr(
        ecr.Repository.from_repository_name(self, "Repository", "my-container-repo")),
    dockerfile=imagebuilder.DockerfileData.from_inline("""
        FROM {{{ imagebuilder:parentImage }}}
        CMD ["echo", "Hello, world!"]
        {{{ imagebuilder:environments }}}
        {{{ imagebuilder:components }}}
        """)
)
```

Java:

```java
ContainerRecipe containerRecipe = ContainerRecipe.Builder.create(this, "CustomDockerfileContainerRecipe")
        .baseImage(BaseContainerImage.fromDockerHub("amazonlinux", "latest"))
        .targetRepository(Repository.fromEcr(Repository.fromRepositoryName(this, "Repository", "my-container-repo")))
        .dockerfile(DockerfileData.fromInline("\nFROM {{{ imagebuilder:parentImage }}}\nCMD [\"echo\", \"Hello, world!\"]\n{{{ imagebuilder:environments }}}\n{{{ imagebuilder:components }}}\n"))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.ImageBuilder.Alpha
var containerRecipe = new ContainerRecipe(this, "CustomDockerfileContainerRecipe", new ContainerRecipeProps {
    BaseImage = BaseContainerImage.FromDockerHub("amazonlinux", "latest"),
    TargetRepository = Repository.FromEcr(Repository.FromRepositoryName(this, "Repository", "my-container-repo")),
    Dockerfile = DockerfileData.FromInline(@"
    FROM {{{ imagebuilder:parentImage }}}
    CMD [""echo"", ""Hello, world!""]
    {{{ imagebuilder:environments }}}
    {{{ imagebuilder:components }}}
    ")
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awsimagebuilderalpha/v2
containerRecipe := imagebuilder.NewContainerRecipe(this, jsii.String("CustomDockerfileContainerRecipe"), &ContainerRecipeProps{
	BaseImage: imagebuilder.BaseContainerImage_*FromDockerHub(jsii.String("amazonlinux"), jsii.String("latest")),
	TargetRepository: imagebuilder.Repository_*FromEcr(ecr.Repository_*FromRepositoryName(this, jsii.String("Repository"), jsii.String("my-container-repo"))),
	Dockerfile: imagebuilder.DockerfileData_FromInline(jsii.String(`
	FROM {{{ imagebuilder:parentImage }}}
	CMD ["echo", "Hello, world!"]
	{{{ imagebuilder:environments }}}
	{{{ imagebuilder:components }}}
	`)),
})
```

## Initializer

TypeScript:

```ts
new DockerfileData()
```

Python:

```python
DockerfileData()
```

Java:

```java
new DockerfileData()
```

C# / .NET:

```csharp
new DockerfileData()
```

Golang:

```go
NewDockerfileData()
```

## Methods

- `fromAsset(scope: Construct, id: string, path: string, options?: AssetOptions): S3DockerfileData` (static) — Uploads dockerfile data from a local file to S3 to use as the dockerfile data.

  **Parameters**

  - `scope` — The construct scope.
  - `id` — Identifier of the construct.
  - `path` — The local path to the dockerfile data file.
  - `options` — S3 asset upload options.

- `fromInline(data: string): DockerfileData // chainable` (static) — Uses an inline string as the dockerfile data.

  **Parameters**

  - `data` — An inline string representing the dockerfile data.

- `fromS3(bucket: IBucket, key: string): S3DockerfileData` (static) — References dockerfile data from a pre-existing S3 object.

  **Parameters**

  - `bucket` — The S3 bucket where the dockerfile data is stored.
  - `key` — The S3 key of the dockerfile data file.

- `render(): DockerfileTemplateConfig` — The rendered Dockerfile value, for use in CloudFormation.

  - For inline dockerfiles, dockerfileTemplateData is the Dockerfile template text
  - For S3-backed dockerfiles, dockerfileTemplateUri is the S3 URL
