docker.image.build¶
- Hook Path:
runway.cfngin.hooks.docker.image.build
Docker image build hook.
Replicates the functionality of the docker image build CLI command.
Added in version 1.18.0.
Args¶
- docker: dict[str, Any] = {}
Options for
docker image build.- custom_context: bool = False
Optional if providing a path to a zip file.
- extra_hosts: dict[str, str] | None = None
Extra hosts to add to
/etc/hostsin the building containers. Defined as a mapping of hostname to IP address.
- forcerm: bool = False
Always remove intermediate containers, even after unsuccessful builds.
- nocache: bool = False
Don’t use cache when set to
True.
- platform: str | None = None
Set platform if server is multi-platform capable. Uses format
os[/arch[/variant]].
- pull: bool = False
Download any updates to the FROM image in the Dockerfile.
- rm: bool = True
Remove intermediate containers.
- squash: bool = False
Squash the resulting image layers into a single layer.
- use_config_proxy: bool = False
If
Trueand if the docker client configuration file (~/.docker/config.jsonby default) contains a proxy configuration, the corresponding environment variables will be set in the container being built.
- ecr_repo: dict[str, str | None] | None = None
Information describing an ECR repository. This is used to construct the repository URL. If providing a value for this field, do not provide a value for
repo.If using a private registry, only
repo_nameis required. If using a public registry,repo_nameandregistry_alias.- account_id: str | None = None
AWS account ID that owns the registry being logged into. If not provided, it will be acquired automatically if needed.
- aws_region: str | None = None
AWS region where the registry is located. If not provided, it will be acquired automatically if needed.
- repo_name: str
The name of the repository.
Returns¶
- type:
- description:
The value of item
imagein the returned object is set to theDockerImagethat was just created.
The returned object is accessible with the hook_data Lookup under the data_key of docker (do not specify a data_key for the hook, this is handled automatically).
Important
Each execution of this hook overwrites any previous values stored in this attribute. It is advices to consume the resulting image object after it has been built, if it will be consumed by a later hook/stack.
Example
pre_deploy:
- path: runway.cfngin.hooks.docker.login
args:
ecr: true
password: ${ecr login-password}
- path: runway.cfngin.hooks.docker.image.build
args:
ecr_repo:
repo_name: ${cfn ${namespace}-test-ecr.Repository}
tags:
- latest
- python3.9
- path: runway.cfngin.hooks.docker.image.push
args:
image: ${hook_data docker.image}