# AssetImage

An image that will be built from a local directory with a Dockerfile.

Extends: ContainerImage › AssetImage

- Source: [`aws-ecs/lib/images/asset-image.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-ecs/lib/images/asset-image.ts#L17)

## Example

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_ecr_assets as ecr_assets } from 'aws-cdk-lib';
import { aws_ecs as ecs } from 'aws-cdk-lib';

declare const networkMode: ecr_assets.NetworkMode;
declare const platform: ecr_assets.Platform;
const assetImage = ecs.AssetImage.fromAsset('directory', /* all optional props */ {
  assetName: 'assetName',
  buildArgs: {
    buildArgsKey: 'buildArgs',
  },
  buildContexts: {
    buildContextsKey: 'buildContexts',
  },
  buildSecrets: {
    buildSecretsKey: 'buildSecrets',
  },
  buildSsh: 'buildSsh',
  cacheDisabled: false,
  cacheFrom: [{
    type: 'type',

    // the properties below are optional
    params: {
      paramsKey: 'params',
    },
  }],
  cacheTo: {
    type: 'type',

    // the properties below are optional
    params: {
      paramsKey: 'params',
    },
  },
  displayName: 'displayName',
  exclude: ['exclude'],
  extraHash: 'extraHash',
  file: 'file',
  followSymlinks: cdk.SymlinkFollowMode.NEVER,
  ignoreMode: cdk.IgnoreMode.GLOB,
  invalidation: {
    buildArgs: false,
    buildContexts: false,
    buildSecrets: false,
    buildSsh: false,
    extraHash: false,
    file: false,
    networkMode: false,
    outputs: false,
    platform: false,
    repositoryName: false,
    target: false,
  },
  networkMode: networkMode,
  outputs: ['outputs'],
  platform: platform,
  target: 'target',
});
```

## Initializer

```ts
new AssetImage(directory: string, props?: AssetImageProps)
```

## Methods

- `bind(scope: Construct, containerDefinition: ContainerDefinition): ContainerImageConfig` — Called when the image is used by a ContainerDefinition.

- `fromAsset(directory: string, props?: AssetImageProps): AssetImage // chainable` (static) — Reference an image that's constructed directly from sources on disk.

  If you already have a `DockerImageAsset` instance, you can use the
  `ContainerImage.fromDockerImageAsset` method instead.

  **Parameters**

  - `directory` — The directory containing the Dockerfile.

- `fromDockerImageAsset(asset: DockerImageAsset): ContainerImage` (static) — Use an existing `DockerImageAsset` for this container image.

  **Parameters**

  - `asset` — The `DockerImageAsset` to use for this container definition.

- `fromEcrRepository(repository: IRepository, tag?: string): EcrImage` (static) — Reference an image in an ECR repository.

  **Parameters**

  - `tag` — If you don't specify this parameter, `latest` is used as default.

- `fromRegistry(name: string, props?: RepositoryImageProps): RepositoryImage` (static) — Reference an image on DockerHub or another online registry.

- `fromTarball(tarballFile: string): ContainerImage` (static) — Use an existing tarball for this container image.

  Use this method if the container image has already been created by another process (e.g. jib)
  and you want to add it as a container image asset.

  **Parameters**

  - `tarballFile` — Absolute path to the tarball.
