DockerBuildOptions

class aws_cdk.DockerBuildOptions(*, build_args=None, cache_disabled=None, cache_from=None, cache_to=None, file=None, platform=None, target_stage=None)

Bases: object

Docker build options.

Parameters:
  • build_args (Optional[Mapping[str, str]]) – Build args. Default: - no build args

  • 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 args are passed

  • 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

  • file (Optional[str]) – Name of the Dockerfile, must relative to the docker build path. Default: Dockerfile

  • platform (Optional[str]) – Set platform if server is multi-platform capable. Requires Docker Engine API v1.38+. Example value: linux/amd64 Default: - no platform specified

  • target_stage (Optional[str]) – Set build target for multi-stage container builds. Any stage defined afterwards will be ignored. Example value: build-env Default: - Build all stages defined in the Dockerfile

ExampleMetadata:

infused

Example:

lambda_.Function(self, "Function",
    code=lambda_.Code.from_asset("/path/to/handler",
        bundling=BundlingOptions(
            image=DockerImage.from_build("/path/to/dir/with/DockerFile",
                build_args={
                    "ARG1": "value1"
                }
            ),
            command=["my", "cool", "command"]
        )
    ),
    runtime=lambda_.Runtime.PYTHON_3_9,
    handler="index.handler"
)

Attributes

build_args

Build args.

Default:
  • no build args

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 args are passed

cache_to

Cache to options to pass to the docker build command.

Default:
  • no cache to args are passed

file

Name of the Dockerfile, must relative to the docker build path.

Default:

Dockerfile

platform

Set platform if server is multi-platform capable. Requires Docker Engine API v1.38+.

Example value: linux/amd64

Default:
  • no platform specified

target_stage

Set build target for multi-stage container builds. Any stage defined afterwards will be ignored.

Example value: build-env

Default:
  • Build all stages defined in the Dockerfile