Skip to content
v2.273.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= no asset name#
Unique identifier of the docker image asset and its potential revisions.

Required if using AppScopedStagingSynthesizer.

directoryNamestringdirectory_namestrdirectoryNameStringDirectoryNamestringDirectoryName*string= Exactly one of `directoryName` a…#
The directory where the Dockerfile is stored, must be relative to the cloud assembly root.
default

Default: Exactly one of directoryName and executable is required

displayNamestringdisplay_namestrdisplayNameStringDisplayNamestringDisplayName*string= The asset hash is used to displa…#
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.

default

Default: The asset hash is used to display the asset

dockerBuildArgs{ [key: string]: string }docker_build_argstyping.Mapping[str, str]dockerBuildArgsMap<String, String>DockerBuildArgsIDictionary<string, string>DockerBuildArgs*map[string]*string= no build args are passed#
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).

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= no additional build contexts#
Build contexts to pass to the `docker build` command.
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= no build secrets are passed#
Build secrets to pass to the `docker build` command.

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= no ssh arg is passed#
SSH agent socket or keys to pass to the `docker buildx` command.
dockerBuildTargetstringdocker_build_targetstrdockerBuildTargetStringDockerBuildTargetstringDockerBuildTarget*string= no target#
Docker target to build to.

Only allowed when directoryName is specified.

dockerCacheDisabledbooleandocker_cache_disabledbooldockerCacheDisabledBooleanDockerCacheDisabledboolDockerCacheDisabled*bool= cache is used#
Disable the cache and pass `--no-cache` to the `docker build` command.
dockerCacheFromDockerCacheOption[]docker_cache_fromtyping.List[DockerCacheOption]dockerCacheFromList<DockerCacheOption>DockerCacheFromDockerCacheOption[]DockerCacheFrom*[]DockerCacheOption= no cache from args are passed#
Cache from options to pass to the `docker build` command.
dockerCacheToDockerCacheOptiondocker_cache_toDockerCacheOptiondockerCacheToDockerCacheOptionDockerCacheToDockerCacheOptionDockerCacheToDockerCacheOption= no cache to args are passed#
Cache to options to pass to the `docker build` command.
dockerFilestringdocker_filestrdockerFileStringDockerFilestringDockerFile*string= no file#
Path to the Dockerfile (relative to the directory).

Only allowed when directoryName is specified.

dockerOutputsstring[]docker_outputstyping.List[str]dockerOutputsList<String>DockerOutputsstring[]DockerOutputs*[]*string= no build args are passed#
Outputs to pass to the `docker build` command.
executablestring[]executabletyping.List[str]executableList<String>Executablestring[]Executable*[]*string= Exactly one of `directoryName` a…#
An external command that will produce the packaged asset.

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

default

Default: Exactly one of directoryName and executable is required

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

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

platformstringplatformstrplatformStringPlatformstringPlatform*string= no platform specified (the curre…#
Platform to build for. _Requires Docker Buildx_.

Specify this property to build images on a specific platform.

default

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

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