aws-cdk-lib.DockerImageAssetSource

interface DockerImageAssetSource

LanguageType name
.NETAmazon.CDK.DockerImageAssetSource
Gogithub.com/aws/aws-cdk-go/awscdk/v2#DockerImageAssetSource
Javasoftware.amazon.awscdk.DockerImageAssetSource
Pythonaws_cdk.DockerImageAssetSource
TypeScript (source)aws-cdk-lib » DockerImageAssetSource

Example

// 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',
  dockerBuildArgs: {
    dockerBuildArgsKey: 'dockerBuildArgs',
  },
  dockerBuildSecrets: {
    dockerBuildSecretsKey: 'dockerBuildSecrets',
  },
  dockerBuildTarget: 'dockerBuildTarget',
  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

NameTypeDescription
sourceHashstringThe hash of the contents of the docker build context.
assetName?stringUnique identifier of the docker image asset and its potential revisions.
directoryName?stringThe directory where the Dockerfile is stored, must be relative to the cloud assembly root.
dockerBuildArgs?{ [string]: string }Build args to pass to the docker build command.
dockerBuildSecrets?{ [string]: string }Build secrets to pass to the docker build command.
dockerBuildTarget?stringDocker target to build to.
dockerCacheFrom?DockerCacheOption[]Cache from options to pass to the docker build command.
dockerCacheTo?DockerCacheOptionCache to options to pass to the docker build command.
dockerFile?stringPath to the Dockerfile (relative to the directory).
dockerOutputs?string[]Outputs to pass to the docker build command.
executable?string[]An external command that will produce the packaged asset.
networkMode?stringNetworking mode for the RUN commands during build. Requires Docker Engine API v1.25+.
platform?stringPlatform to build for. Requires Docker Buildx.

sourceHash

Type: string

The hash of the contents of the docker build context.

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


assetName?

Type: string (optional, default: no asset name)

Unique identifier of the docker image asset and its potential revisions.

Required if using AppScopedStagingSynthesizer.


directoryName?

Type: string (optional, default: Exactly one of directoryName and executable is required)

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


dockerBuildArgs?

Type: { [string]: string } (optional, default: 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.


dockerBuildSecrets?

Type: { [string]: string } (optional, default: 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.


dockerBuildTarget?

Type: string (optional, default: no target)

Docker target to build to.

Only allowed when directoryName is specified.


dockerCacheFrom?

Type: DockerCacheOption[] (optional, default: no cache from args are passed)

Cache from options to pass to the docker build command.


dockerCacheTo?

Type: DockerCacheOption (optional, default: no cache to args are passed)

Cache to options to pass to the docker build command.


dockerFile?

Type: string (optional, default: no file)

Path to the Dockerfile (relative to the directory).

Only allowed when directoryName is specified.


dockerOutputs?

Type: string[] (optional, default: no build args are passed)

Outputs to pass to the docker build command.


executable?

Type: string[] (optional, default: Exactly one of directoryName and executable is required)

An external command that will produce the packaged asset.

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


networkMode?

Type: string (optional, default: 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.


platform?

Type: string (optional, default: no platform specified (the current machine architecture will be used))

Platform to build for. Requires Docker Buildx.

Specify this property to build images on a specific platform.