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.
New in version 1.18.0.
Args
- docker: Optional[Dict[str, Any]] = {}
Options for
docker image build
.- custom_context: bool = False
Optional if providing a path to a zip file.
- extra_hosts: Optional[Dict[str, str]] = None
Extra hosts to add to
/etc/hosts
in the building containers. Defined as a mapping of hostname to IP address.
- forcerm: bool = False
Always remove intermediate containers, even after unsuccessful builds.
- isolation: Optional[str] = None
Isolation technology used during build.
- network_mode: Optional[str] = None
Network mode for the run commands during build.
- nocache: bool = False
Don’t use cache when set to
True
.
- platform: Optional[str] = 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.
- tag: Optional[str] = None
Optional name and tag to apply to the base image when it is built.
- target: Optional[str] = None
Name of the build-stage to build in a multi-stage Dockerfile.
- timeout: Optional[int] = None
HTTP timeout.
- use_config_proxy: bool = False
If
True
and if the docker client configuration file (~/.docker/config.json
by default) contains a proxy configuration, the corresponding environment variables will be set in the container being built.
- dockerfile: Optional[str] = "./Dockerfile"
Path within the build context to the Dockerfile.
- ecr_repo: Optional[Dict[str, Optional[str]]] = 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_name
is required. If using a public registry,repo_name
andregistry_alias
.- account_id: Optional[str] = None
AWS account ID that owns the registry being logged into. If not provided, it will be acquired automatically if needed.
- aws_region: Optional[str] = None
AWS region where the registry is located. If not provided, it will be acquired automatically if needed.
- registry_alias: Optional[str] = None
If it is a public repository, provide the alias.
- repo_name: str
The name of the repository.
- path: Optional[str]
Path to the directory containing the Dockerfile.
- repo: Optional[str] = None
URI of a non Docker Hub repository where the image will be stored. If providing one of the other repo values, leave this value empty.
- tags: Optional[List[str]] = ["latest"]
List of tags to apply to the image.
Returns
- type
- description
The value of item
image
in the returned object is set to theDockerImage
that 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}