Skip to content
v2.274.0

DockerImageAssetSource Struct ​

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';
const dockerImageAssetSource: cdk.DockerImageAssetSource = {
  sourceHash: 'sourceHash',

  // the properties below are optional
  assetName: 'assetName',
  directoryName: 'directoryName',
  displayName: 'displayName',
  dockerBuildArgs: {
    dockerBuildArgsKey: 'dockerBuildArgs',
  },
  dockerBuildContexts: {
    dockerBuildContextsKey: 'dockerBuildContexts',
  },
  dockerBuildSecrets: {
    dockerBuildSecretsKey: 'dockerBuildSecrets',
  },
  dockerBuildSsh: 'dockerBuildSsh',
  dockerBuildTarget: 'dockerBuildTarget',
  dockerCacheDisabled: false,
  dockerCacheFrom: [{
    type: 'type',

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

    // the properties below are optional
    params: {
      paramsKey: 'params',
    },
  },
  dockerFile: 'dockerFile',
  dockerOutputs: ['dockerOutputs'],
  executable: ['executable'],
  networkMode: 'networkMode',
  platform: 'platform',
};

Properties ​

assetNamestringasset_namestrassetNameStringAssetNamestringAssetName*string#
Unique identifier of the docker image asset and its potential revisions.

Default: no asset name

Required if using AppScopedStagingSynthesizer.

directoryNamestringdirectory_namestrdirectoryNameStringDirectoryNamestringDirectoryName*string#
The directory where the Dockerfile is stored, must be relative to the cloud assembly root.

Default: Exactly one of directoryName and executable is required

displayNamestringdisplay_namestrdisplayNameStringDisplayNamestringDisplayName*string#
A display name for this asset.

Default: The asset hash is used to display the asset

If supplied, the display name will be used in locations where the asset identifier is printed, like in the CLI progress information.

dockerBuildArgs{ [key: string]: string }docker_build_argstyping.Mapping[str, str]dockerBuildArgsMap<String, String>DockerBuildArgsIDictionary<string, string>DockerBuildArgs*map[string]*string#
Build args to pass to the `docker build` command.

Default: no build args are passed

Since Docker build arguments are resolved before deployment, keys and values cannot refer to unresolved tokens (such as lambda.functionArn or queue.queueUrl).

Only allowed when directoryName is specified.

dockerBuildContexts{ [key: string]: string }docker_build_contextstyping.Mapping[str, str]dockerBuildContextsMap<String, String>DockerBuildContextsIDictionary<string, string>DockerBuildContexts*map[string]*string#
Build contexts to pass to the `docker build` command.

Default: no additional build contexts

notes

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).

Only allowed when directoryName is specified.

dockerBuildSecrets{ [key: string]: string }docker_build_secretstyping.Mapping[str, str]dockerBuildSecretsMap<String, String>DockerBuildSecretsIDictionary<string, string>DockerBuildSecrets*map[string]*string#
Build secrets to pass to the `docker build` command.

Default: no build secrets are passed

Since Docker build secrets are resolved before deployment, keys and values cannot refer to unresolved tokens (such as lambda.functionArn or queue.queueUrl).

Only allowed when directoryName is specified.

dockerBuildSshstringdocker_build_sshstrdockerBuildSshStringDockerBuildSshstringDockerBuildSsh*string#
SSH agent socket or keys to pass to the `docker buildx` command.

Default: no ssh arg is passed

dockerBuildTargetstringdocker_build_targetstrdockerBuildTargetStringDockerBuildTargetstringDockerBuildTarget*string#
Docker target to build to.

Default: no target

Only allowed when directoryName is specified.

dockerCacheDisabledbooleandocker_cache_disabledbooldockerCacheDisabledBooleanDockerCacheDisabledboolDockerCacheDisabled*bool#
Disable the cache and pass `--no-cache` to the `docker build` command.

Default: cache is used

dockerCacheFromDockerCacheOption[]docker_cache_fromtyping.List[DockerCacheOption]dockerCacheFromList<DockerCacheOption>DockerCacheFromDockerCacheOption[]DockerCacheFrom*[]DockerCacheOption#
Cache from options to pass to the `docker build` command.

Default: no cache from args are passed

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

Default: no cache to args are passed

dockerFilestringdocker_filestrdockerFileStringDockerFilestringDockerFile*string#
Path to the Dockerfile (relative to the directory).

Default: no file

Only allowed when directoryName is specified.

dockerOutputsstring[]docker_outputstyping.List[str]dockerOutputsList<String>DockerOutputsstring[]DockerOutputs*[]*string#
Outputs to pass to the `docker build` command.

Default: no build args are passed

executablestring[]executabletyping.List[str]executableList<String>Executablestring[]Executable*[]*string#
An external command that will produce the packaged asset.

Default: Exactly one of directoryName and executable is required

The command should produce the name of a local Docker image on stdout.

networkModestringnetwork_modestrnetworkModeStringNetworkModestringNetworkMode*string#
Networking mode for the RUN commands during build. _Requires Docker Engine API v1.25+_.

Default: no networking mode specified

Specify this property to build images on a specific networking mode.

platformstringplatformstrplatformStringPlatformstringPlatform*string#
Platform to build for. _Requires Docker Buildx_.

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

Specify this property to build images on a specific platform.

sourceHashstringsource_hashstrsourceHashStringSourceHashstringSourceHash*stringrequired#
The hash of the contents of the docker build context.
notes

This hash is used throughout the system to identify this image and avoid duplicate work in case the source did not change.

NOTE: this means that if you wish to update your docker image, you must make a modification to the source (e.g. add some metadata to your Dockerfile).