runway.cfngin.hooks.docker.image package

Docker image actions & argument parsers.

Replicates the functionality of docker image CLI commands.

class runway.cfngin.hooks.docker.image.DockerImageBuildApiOptions(*, buildargs: Optional[Dict[str, Any]] = None, custom_context: bool = False, extra_hosts: Optional[Dict[str, Any]] = None, forcerm: bool = False, isolation: Optional[str] = None, network_mode: Optional[str] = None, nocache: bool = False, platform: Optional[str] = None, pull: bool = False, rm: bool = True, squash: bool = False, tag: Optional[str] = None, target: Optional[str] = None, timeout: Optional[int] = None, use_config_proxy: bool = False, **kwargs: Any)[source]

Bases: runway.cfngin.hooks.docker.data_models.BaseModel

Options for controlling Docker.

buildargs

Dict of build-time variables that will be passed to Docker.

Type

Dict[str, Any]

custom_context

Whether to use custom context when providing a file object.

Type

bool

extra_hosts

Extra hosts to add to /etc/hosts in the build containers. Defined as a mapping of hostmane to IP address.

Type

Optional[Dict[str, str]]

forcerm

Always remove intermediate containers, even after unsuccessful builds.

Type

bool

isolation

Isolation technology used during build.

Type

Optional[str]

network_mode

Network mode for the run commands during build.

Type

Optional[str]

nocache

Whether to use cache.

Type

bool

platform

Set platform if server is multi-platform capable. Uses format os[/arch[/variant]].

Type

Optional[str]

pull

Whether to download any updates to the FROM image in the Dockerfile.

Type

bool

rm

Whether to remove intermediate containers.

Type

bool

squash

Whether to squash the resulting image layers into a single layer.

Type

bool

tag

Optional name and tag to apply to the base image when it is built.

Type

Optional[str]

target

Name of the build-stage to build in a multi-stage Dockerfile.

Type

Optional[str]

timeout

HTTP timeout.

use_config_proxy

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.

Type

bool

Instantiate class.

Parameters
  • buildargs – Dict of build-time variables that will be passed to Docker.

  • custom_context – Whether to use custom context when providing a file object.

  • extra_hosts – Extra hosts to add to /etc/hosts in the build containers. Defined as a mapping of hostmane to IP address.

  • forcerm – Always remove intermediate containers, even after unsuccessful builds.

  • isolation – Isolation technology used during build.

  • network_mode – Network mode for the run commands during build.

  • nocache – Whether to use cache.

  • platform – Set platform if server is multi-platform capable. Uses format os[/arch[/variant]].

  • pull – Whether to download any updates to the FROM image in the Dockerfile.

  • rm – Whether to remove intermediate containers.

  • squash – Whether to squash the resulting image layers into a single layer.

  • tag – Optional name and tag to apply to the base image when it is built.

  • target – Name of the build-stage to build in a multi-stage Dockerfile.

  • timeout – HTTP timeout.

  • use_config_proxy – 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.

__eq__(other: typing.Any)bool

Evaluate equal comparison operator.

__getitem__(name: str)bool

Implement evaluation of self[name].

Parameters

name – The value to look for.

Raises

KeyError – Object does not contain a field of the name provided.

__iter__()ItemsView[str, typing.Any]

Iterate object.

__setitem__(name: str, value: typing.Any)None

Implement assignment to self[key].

Parameters
  • name – Attribute name to associate with a value.

  • value – Value of a key/attribute.

dict()Dict[str, Any]

Return object as a dict.

find(query: str, default: Optional[typing.Any] = None, **kwargs: typing.Any)typing.Any

Find a value in the object.

get(name: str, default: Optional[typing.Any] = None)typing.Any

Get a value or return default if it is not found.

Attr:

name: The value to look for. default: Returned if no other value is found.

classmethod parse_obj(obj: Any, context: Optional[CfnginContext] = None)Model

Parse object.

class runway.cfngin.hooks.docker.image.ImageBuildArgs(*, context: Optional[CfnginContext] = None, docker: Optional[Dict[str, Any]] = None, dockerfile: str = './Dockerfile', ecr_repo: Optional[Dict[str, Optional[str]]] = None, path: Optional[Union[Path, str]] = None, repo: Optional[str] = None, tags: Optional[List[str]] = None, **_: Any)[source]

Bases: runway.cfngin.hooks.docker.data_models.BaseModel

Args passed to image.build.

docker

Options for docker image build.

Type

DockerImageBuildApiOptions

dockerfile

Path within the build context to the Dockerfile.

Type

str

ecr_repo

AWS Elastic Container Registry repository information. Providing this will automatically construct the repo URI. If provided, do not provide repo.

If using a private registry, only repo_name is required. If using a public registry, repo_name and registry_alias.

path

Path to the directory containing the Dockerfile.

Type

Path

repo

URI of a non Docker Hub repository where the image will be stored.

Type

Optional[str]

tags

List of tags to apply to the image.

Type

List[str]

Instantiate class.

Parameters
  • context – CFNgin context object.

  • docker – Options for docker image build.

  • dockerfile – Path within the build context to the Dockerfile.

  • ecr_repo – AWS Elastic Container Registry repository information. Providing this will automatically create the repo URI. If provided, do not provide repo.

  • path – Path to the directory containing the Dockerfile.

  • repo – 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 – List of tags to apply to the image. If not provided, ["latest"] will be used.

__eq__(other: typing.Any)bool

Evaluate equal comparison operator.

__getitem__(name: str)bool

Implement evaluation of self[name].

Parameters

name – The value to look for.

Raises

KeyError – Object does not contain a field of the name provided.

__iter__()ItemsView[str, typing.Any]

Iterate object.

__setitem__(name: str, value: typing.Any)None

Implement assignment to self[key].

Parameters
  • name – Attribute name to associate with a value.

  • value – Value of a key/attribute.

dict()Dict[str, Any]

Return object as a dict.

find(query: str, default: Optional[typing.Any] = None, **kwargs: typing.Any)typing.Any

Find a value in the object.

get(name: str, default: Optional[typing.Any] = None)typing.Any

Get a value or return default if it is not found.

Attr:

name: The value to look for. default: Returned if no other value is found.

classmethod parse_obj(obj: Any, context: Optional[CfnginContext] = None)Model

Parse object.

static determine_repo(context: Optional[CfnginContext] = None, ecr_repo: Optional[Dict[str, Optional[str]]] = None, repo: Optional[str] = None)Optional[str][source]

Determine repo URI.

Parameters
  • context – CFNgin context.

  • ecr_repo – AWS Elastic Container Registry options.

  • repo – URI of a non Docker Hub repository.

class runway.cfngin.hooks.docker.image.ImagePushArgs(*, ecr_repo: Optional[Dict[str, Any]] = None, image: Optional[DockerImage] = None, repo: Optional[str] = None, tags: Optional[List[str]] = None, **kwargs: Any)[source]

Bases: runway.cfngin.hooks.docker.data_models.BaseModel

Args passed to image.push.

repo

URI of a non Docker Hub repository where the image will be stored.

Type

Optional[str]

tags

List of tags to push.

Type

List[str]

Instantiate class.

Parameters
  • ecr_repo – AWS Elastic Container Registry repository information. Providing this will automatically create the repo URI. If provided, do not provide repo.

  • image – Image to push.

  • repo – 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 – List of tags to push.

__eq__(other: typing.Any)bool

Evaluate equal comparison operator.

__getitem__(name: str)bool

Implement evaluation of self[name].

Parameters

name – The value to look for.

Raises

KeyError – Object does not contain a field of the name provided.

__iter__()ItemsView[str, typing.Any]

Iterate object.

__setitem__(name: str, value: typing.Any)None

Implement assignment to self[key].

Parameters
  • name – Attribute name to associate with a value.

  • value – Value of a key/attribute.

static determine_repo(context: Optional[CfnginContext] = None, ecr_repo: Optional[Dict[str, Optional[str]]] = None, image: Optional[DockerImage] = None, repo: Optional[str] = None)Optional[str][source]

Determine repo URI.

Parameters
  • context – CFNgin context.

  • ecr_repo – AWS Elastic Container Registry options.

  • image – Docker image object.

  • repo – URI of a non Docker Hub repository.

dict()Dict[str, Any]

Return object as a dict.

find(query: str, default: Optional[typing.Any] = None, **kwargs: typing.Any)typing.Any

Find a value in the object.

get(name: str, default: Optional[typing.Any] = None)typing.Any

Get a value or return default if it is not found.

Attr:

name: The value to look for. default: Returned if no other value is found.

classmethod parse_obj(obj: Any, context: Optional[CfnginContext] = None)Model

Parse object.

class runway.cfngin.hooks.docker.image.ImageRemoveArgs(*, ecr_repo: Optional[Dict[str, Any]] = None, force: bool = False, image: DockerImage = None, noprune: bool = False, repo: Optional[str] = None, tags: Optional[List[str]] = None, **kwargs: Any)[source]

Bases: runway.cfngin.hooks.docker.data_models.BaseModel

Args passed to image.remove.

force

Whether to force the removal of the image.

Type

bool

noprune

Whether to delete untagged parents.

Type

bool

repo

URI of a non Docker Hub repository where the image will be stored.

Type

Optional[str]

tags

List of tags to remove.

Type

List[str]

Instantiate class.

Parameters
  • ecr_repo – AWS Elastic Container Registry repository information. Providing this will automatically create the repo URI. If provided, do not provide repo.

  • force – Whether to force the removal of the image.

  • image – Image to push.

  • noprune – Whether to delete untagged parents.

  • repo – 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 – List of tags to remove.

__eq__(other: typing.Any)bool

Evaluate equal comparison operator.

__getitem__(name: str)bool

Implement evaluation of self[name].

Parameters

name – The value to look for.

Raises

KeyError – Object does not contain a field of the name provided.

__iter__()ItemsView[str, typing.Any]

Iterate object.

__setitem__(name: str, value: typing.Any)None

Implement assignment to self[key].

Parameters
  • name – Attribute name to associate with a value.

  • value – Value of a key/attribute.

dict()Dict[str, Any]

Return object as a dict.

find(query: str, default: Optional[typing.Any] = None, **kwargs: typing.Any)typing.Any

Find a value in the object.

get(name: str, default: Optional[typing.Any] = None)typing.Any

Get a value or return default if it is not found.

Attr:

name: The value to look for. default: Returned if no other value is found.

classmethod parse_obj(obj: Any, context: Optional[CfnginContext] = None)Model

Parse object.

static determine_repo(context: Optional[CfnginContext] = None, ecr_repo: Optional[Dict[str, Optional[str]]] = None, image: Optional[DockerImage] = None, repo: Optional[str] = None)Optional[str][source]

Determine repo URI.

Parameters
  • context – CFNgin context.

  • ecr_repo – AWS Elastic Container Registry options.

  • image – Docker image object.

  • repo – URI of a non Docker Hub repository.

runway.cfngin.hooks.docker.image.build(*, context: CfnginContext, **kwargs: Any)DockerHookData[source]

Docker image build hook.

Replicates the functionality of docker image build CLI command.

kwargs are parsed by ImageBuildArgs.

runway.cfngin.hooks.docker.image.push(*, context: CfnginContext, **kwargs: Any)DockerHookData[source]

Docker image push hook.

Replicates the functionality of docker image push CLI command.

kwargs are parsed by ImagePushArgs.

runway.cfngin.hooks.docker.image.remove(*, context: CfnginContext, **kwargs: Any)DockerHookData[source]

Docker image push remove.

Replicates the functionality of docker image push CLI command.

kwargs are parsed by ImageRemoveArgs.