AWS Fundamentals Logo
AWS Fundamentals
L2 Construct

DockerImageAsset

An asset that represents a Docker image. The image will be created in build time and uploaded to an ECR repository.

Import

import { DockerImageAsset } from 'aws-cdk-lib/aws-ecr-assets';

Or use the module namespace:

import * as ecr_assets from 'aws-cdk-lib/aws-ecr-assets';
// ecr_assets.DockerImageAsset

Properties

Configuration passed to the constructor as DockerImageAssetProps.

directoryRequired
string

The directory where the Dockerfile is stored. Any directory inside with a name that matches the CDK output folder (cdk.out by default) will be excluded from the asset

15 properties inherited from DockerImageAssetOptions
assetNameOptionalinherited from DockerImageAssetOptions
string

Unique identifier of the docker image asset and its potential revisions. Required if using AppScopedStagingSynthesizer.

Default: - no asset name

buildArgsOptionalinherited from DockerImageAssetOptions
{ [key: string]: string }

Build args to pass to the `docker build` command. Since Docker build arguments are resolved before deployment, keys and values cannot refer to unresolved tokens (such as `lambda.functionArn` or `queue.queueUrl`).

Default: - no build args are passed

buildContextsOptionalinherited from DockerImageAssetOptions
{ [key: string]: string }

Build contexts to pass to the `docker build` command. Build contexts can be used to specify additional directories or images to use during the build. Each entry specifies a named build context and its source (a directory path, a URL, or a docker image). Since Docker build contexts are resolved before deployment, keys and values cannot refer to unresolved tokens (such as `lambda.functionArn` or `queue.queueUrl`).

Default: - no additional build contexts

buildSecretsOptionalinherited from DockerImageAssetOptions
{ [key: string]: string }

Build secrets. Docker BuildKit must be enabled to use build secrets.

Default: - no build secrets

buildSshOptionalinherited from DockerImageAssetOptions
string

SSH agent socket or keys to pass to the `docker build` command. Docker BuildKit must be enabled to use the ssh flag

Default: - no --ssh flag

cacheDisabledOptionalinherited from DockerImageAssetOptions
boolean

Disable the cache and pass `--no-cache` to the `docker build` command.

Default: - cache is used

cacheFromOptionalinherited from DockerImageAssetOptions
DockerCacheOption[]

Cache from options to pass to the `docker build` command.

Default: - no cache from options are passed to the build command

cacheToOptionalinherited from DockerImageAssetOptions
DockerCacheOption

Cache to options to pass to the `docker build` command.

Default: - no cache to options are passed to the build command

displayNameOptionalinherited from DockerImageAssetOptions
string

A display name for this asset. If supplied, the display name will be used in locations where the asset identifier is printed, like in the CLI progress information. If the same asset is added multiple times, the display name of the first occurrence is used. If `assetName` is given, it will also be used as the default `displayName`. Otherwise, the default is the construct path of the ImageAsset construct, with respect to the enclosing stack. If the asset is produced by a construct helper function (such as `lambda.Code.fromAssetImage()`), this will look like `MyFunction/AssetImage`. We use the stack-relative construct path so that in the common case where you have multiple stacks with the same asset, we won't show something like `/MyBetaStack/MyFunction/Code` when you are actually deploying to production.

Default: - Stack-relative construct path

fileOptionalinherited from DockerImageAssetOptions
string

Path to the Dockerfile (relative to the directory).

Default: 'Dockerfile'

invalidationOptionalinherited from DockerImageAssetOptions
DockerImageAssetInvalidationOptions

Options to control which parameters are used to invalidate the asset hash.

Default: - hash all parameters

networkModeOptionalinherited from DockerImageAssetOptions
NetworkMode

Networking mode for the RUN commands during build. Support docker API 1.25+.

Default: - no networking mode specified (the default networking mode `NetworkMode.DEFAULT` will be used)

outputsOptionalinherited from DockerImageAssetOptions
string[]

Outputs to pass to the `docker build` command.

Default: - no outputs are passed to the build command (default outputs are used)

platformOptionalinherited from DockerImageAssetOptions
Platform

Platform to build for. _Requires Docker Buildx_.

Default: - no platform specified (the current machine architecture will be used)

targetOptionalinherited from DockerImageAssetOptions
string

Docker target to build to.

Default: - no target

1 property inherited from FileFingerprintOptions
extraHashOptionalinherited from FileFingerprintOptions
string

Extra information to encode into the fingerprint (e.g. build instructions and other inputs).

Default: - hash is only based on source content

3 properties inherited from FileCopyOptions
excludeOptionalinherited from FileCopyOptions
string[]

File paths matching the patterns will be excluded. See `ignoreMode` to set the matching behavior. Has no effect on Assets bundled using the `bundling` property.

Default: - nothing is excluded

followSymlinksOptionalinherited from FileCopyOptions
SymlinkFollowMode

A strategy for how to handle symlinks.

Default: SymlinkFollowMode.NEVER

ignoreModeOptionalinherited from FileCopyOptions
IgnoreMode

The ignore behavior to use for `exclude` patterns.

Default: IgnoreMode.GLOB

Learn AWS the Practical Way

Our bi-weekly newsletter teaches hands-on AWS fundamentals. No certification fluff - just practical knowledge.

Subscribe to Newsletter

Quick Facts

LevelL2 (Higher-level)
Moduleaws-ecr-assets
Properties20

Related Constructs

External Links