DockerImageAssetSource

class aws_cdk.DockerImageAssetSource(*, source_hash, asset_name=None, directory_name=None, docker_build_args=None, docker_build_secrets=None, docker_build_ssh=None, docker_build_target=None, docker_cache_disabled=None, docker_cache_from=None, docker_cache_to=None, docker_file=None, docker_outputs=None, executable=None, network_mode=None, platform=None)

Bases: object

Parameters:
  • source_hash (str) – 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).

  • asset_name (Optional[str]) – Unique identifier of the docker image asset and its potential revisions. Required if using AppScopedStagingSynthesizer. Default: - no asset name

  • directory_name (Optional[str]) – The directory where the Dockerfile is stored, must be relative to the cloud assembly root. Default: - Exactly one of directoryName and executable is required

  • docker_build_args (Optional[Mapping[str, str]]) – 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. Default: - no build args are passed

  • docker_build_secrets (Optional[Mapping[str, str]]) – 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. Default: - no build secrets are passed

  • docker_build_ssh (Optional[str]) – SSH agent socket or keys to pass to the docker buildx command. Default: - no ssh arg is passed

  • docker_build_target (Optional[str]) – Docker target to build to. Only allowed when directoryName is specified. Default: - no target

  • docker_cache_disabled (Optional[bool]) – Disable the cache and pass --no-cache to the docker build command. Default: - cache is used

  • docker_cache_from (Optional[Sequence[Union[DockerCacheOption, Dict[str, Any]]]]) – Cache from options to pass to the docker build command. Default: - no cache from args are passed

  • docker_cache_to (Union[DockerCacheOption, Dict[str, Any], None]) – Cache to options to pass to the docker build command. Default: - no cache to args are passed

  • docker_file (Optional[str]) – Path to the Dockerfile (relative to the directory). Only allowed when directoryName is specified. Default: - no file

  • docker_outputs (Optional[Sequence[str]]) – Outputs to pass to the docker build command. Default: - no build args are passed

  • executable (Optional[Sequence[str]]) – An external command that will produce the packaged asset. The command should produce the name of a local Docker image on stdout. Default: - Exactly one of directoryName and executable is required

  • network_mode (Optional[str]) – 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. Default: - no networking mode specified

  • platform (Optional[str]) – Platform to build for. Requires Docker Buildx. Specify this property to build images on a specific platform. Default: - no platform specified (the current machine architecture will be used)

ExampleMetadata:

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk

docker_image_asset_source = cdk.DockerImageAssetSource(
    source_hash="sourceHash",

    # the properties below are optional
    asset_name="assetName",
    directory_name="directoryName",
    docker_build_args={
        "docker_build_args_key": "dockerBuildArgs"
    },
    docker_build_secrets={
        "docker_build_secrets_key": "dockerBuildSecrets"
    },
    docker_build_ssh="dockerBuildSsh",
    docker_build_target="dockerBuildTarget",
    docker_cache_disabled=False,
    docker_cache_from=[cdk.DockerCacheOption(
        type="type",

        # the properties below are optional
        params={
            "params_key": "params"
        }
    )],
    docker_cache_to=cdk.DockerCacheOption(
        type="type",

        # the properties below are optional
        params={
            "params_key": "params"
        }
    ),
    docker_file="dockerFile",
    docker_outputs=["dockerOutputs"],
    executable=["executable"],
    network_mode="networkMode",
    platform="platform"
)

Attributes

asset_name

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

Required if using AppScopedStagingSynthesizer.

Default:
  • no asset name

directory_name

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

Default:
  • Exactly one of directoryName and executable is required

docker_build_args

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.

Default:
  • no build args are passed

docker_build_secrets

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.

Default:
  • no build secrets are passed

docker_build_ssh

SSH agent socket or keys to pass to the docker buildx command.

Default:
  • no ssh arg is passed

docker_build_target

Docker target to build to.

Only allowed when directoryName is specified.

Default:
  • no target

docker_cache_disabled

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

Default:
  • cache is used

docker_cache_from

Cache from options to pass to the docker build command.

Default:
  • no cache from args are passed

docker_cache_to

Cache to options to pass to the docker build command.

Default:
  • no cache to args are passed

docker_file

Path to the Dockerfile (relative to the directory).

Only allowed when directoryName is specified.

Default:
  • no file

docker_outputs

Outputs to pass to the docker build command.

Default:
  • no build args are passed

executable

An external command that will produce the packaged asset.

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

Default:
  • Exactly one of directoryName and executable is required

network_mode

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.

Default:
  • no networking mode specified

platform

Platform to build for. Requires Docker Buildx.

Specify this property to build images on a specific platform.

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

source_hash

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