DockerImageSource

class aws_cdk.cloud_assembly_schema.DockerImageSource(*, cache_disabled=None, cache_from=None, cache_to=None, directory=None, docker_build_args=None, docker_build_secrets=None, docker_build_ssh=None, docker_build_target=None, docker_file=None, docker_outputs=None, executable=None, network_mode=None, platform=None)

Bases: object

Properties for how to produce a Docker image from a source.

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

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

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

  • directory (Optional[str]) – The directory containing the Docker image build instructions. This path is relative to the asset manifest location. Default: - Exactly one of directory and executable is required

  • docker_build_args (Optional[Mapping[str, str]]) – Additional build arguments. Only allowed when directory is set. Default: - No additional build arguments

  • docker_build_secrets (Optional[Mapping[str, str]]) – Additional build secrets. Only allowed when directory is set. Default: - No additional build secrets

  • docker_build_ssh (Optional[str]) – SSH agent socket or keys. Requires building with docker buildkit. Default: - No ssh flag is set

  • docker_build_target (Optional[str]) – Target build stage in a Dockerfile with multiple build stages. Only allowed when directory is set. Default: - The last stage in the Dockerfile

  • docker_file (Optional[str]) – The name of the file with build instructions. Only allowed when directory is set. Default: “Dockerfile”

  • docker_outputs (Optional[Sequence[str]]) – Outputs. Default: - no outputs are passed to the build command (default outputs are used)

  • executable (Optional[Sequence[str]]) – A command-line executable that returns the name of a local Docker image on stdout after being run. Default: - Exactly one of directory 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/architecture. Default: - current machine platform

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.cloud_assembly_schema as cloud_assembly_schema

docker_image_source = cloud_assembly_schema.DockerImageSource(
    cache_disabled=False,
    cache_from=[cloud_assembly_schema.DockerCacheOption(
        type="type",

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

        # the properties below are optional
        params={
            "params_key": "params"
        }
    ),
    directory="directory",
    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_file="dockerFile",
    docker_outputs=["dockerOutputs"],
    executable=["executable"],
    network_mode="networkMode",
    platform="platform"
)

Attributes

cache_disabled

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

Default:
  • cache is used

cache_from

Cache from options to pass to the docker build command.

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

See:

https://docs.docker.com/build/cache/backends/

cache_to

Cache to options to pass to the docker build command.

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

See:

https://docs.docker.com/build/cache/backends/

directory

The directory containing the Docker image build instructions.

This path is relative to the asset manifest location.

Default:
  • Exactly one of directory and executable is required

docker_build_args

Additional build arguments.

Only allowed when directory is set.

Default:
  • No additional build arguments

docker_build_secrets

Additional build secrets.

Only allowed when directory is set.

Default:
  • No additional build secrets

docker_build_ssh

SSH agent socket or keys.

Requires building with docker buildkit.

Default:
  • No ssh flag is set

docker_build_target

Target build stage in a Dockerfile with multiple build stages.

Only allowed when directory is set.

Default:
  • The last stage in the Dockerfile

docker_file

The name of the file with build instructions.

Only allowed when directory is set.

Default:

“Dockerfile”

docker_outputs

Outputs.

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

See:

https://docs.docker.com/engine/reference/commandline/build/#custom-build-outputs

executable

A command-line executable that returns the name of a local Docker image on stdout after being run.

Default:
  • Exactly one of directory 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/architecture.

Default:
  • current machine platform