runway.cfngin.hooks.docker.image package

Docker image actions & argument parsers.

Replicates the functionality of docker image CLI commands.

pydantic model runway.cfngin.hooks.docker.image.DockerImageBuildApiOptions[source]

Bases: BaseModel

Options for controlling Docker.

Show JSON schema
{
   "title": "DockerImageBuildApiOptions",
   "description": "Options for controlling Docker.",
   "type": "object",
   "properties": {
      "buildargs": {
         "additionalProperties": true,
         "default": {},
         "title": "Buildargs",
         "type": "object"
      },
      "custom_context": {
         "default": false,
         "title": "Custom Context",
         "type": "boolean"
      },
      "extra_hosts": {
         "additionalProperties": {
            "type": "string"
         },
         "default": {},
         "title": "Extra Hosts",
         "type": "object"
      },
      "forcerm": {
         "default": false,
         "title": "Forcerm",
         "type": "boolean"
      },
      "isolation": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Isolation"
      },
      "network_mode": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Network Mode"
      },
      "nocache": {
         "default": false,
         "title": "Nocache",
         "type": "boolean"
      },
      "platform": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Platform"
      },
      "pull": {
         "default": false,
         "title": "Pull",
         "type": "boolean"
      },
      "rm": {
         "default": true,
         "title": "Rm",
         "type": "boolean"
      },
      "squash": {
         "default": false,
         "title": "Squash",
         "type": "boolean"
      },
      "tag": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Tag"
      },
      "target": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Target"
      },
      "timeout": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Timeout"
      },
      "use_config_proxy": {
         "default": false,
         "title": "Use Config Proxy",
         "type": "boolean"
      }
   }
}

field buildargs: dict[str, Any] = {}

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

field custom_context: bool = False

Whether to use custom context when providing a file object.

field extra_hosts: dict[str, str] = {}

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

field forcerm: bool = False

Always remove intermediate containers, even after unsuccessful builds.

field isolation: str | None = None

Isolation technology used during build.

field network_mode: str | None = None

Network mode for the run commands during build.

field nocache: bool = False

Whether to use cache.

field platform: str | None = None

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

field pull: bool = False

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

field rm: bool = True

Whether to remove intermediate containers.

field squash: bool = False

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

field tag: str | None = None

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

field target: str | None = None

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

field timeout: int | None = None

HTTP timeout.

field 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.

pydantic model runway.cfngin.hooks.docker.image.ImageBuildArgs[source]

Bases: BaseModel

Args passed to image.build.

Show JSON schema
{
   "title": "ImageBuildArgs",
   "type": "object",
   "properties": {
      "ctx": {
         "default": null,
         "title": "Ctx"
      },
      "ecr_repo": {
         "anyOf": [
            {
               "$ref": "#/$defs/ElasticContainerRegistryRepository"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "path": {
         "default": "/home/docs/checkouts/readthedocs.org/user_builds/runway/checkouts/stable/docs/source",
         "format": "directory-path",
         "title": "Path",
         "type": "string"
      },
      "dockerfile": {
         "default": "Dockerfile",
         "title": "Dockerfile",
         "type": "string"
      },
      "repo": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Repo"
      },
      "docker": {
         "$ref": "#/$defs/DockerImageBuildApiOptions",
         "default": {
            "buildargs": {},
            "custom_context": false,
            "extra_hosts": {},
            "forcerm": false,
            "isolation": null,
            "network_mode": null,
            "nocache": false,
            "platform": null,
            "pull": false,
            "rm": true,
            "squash": false,
            "tag": null,
            "target": null,
            "timeout": null,
            "use_config_proxy": false
         }
      },
      "tags": {
         "default": [
            "latest"
         ],
         "items": {
            "type": "string"
         },
         "title": "Tags",
         "type": "array"
      }
   },
   "$defs": {
      "DockerImageBuildApiOptions": {
         "description": "Options for controlling Docker.",
         "properties": {
            "buildargs": {
               "additionalProperties": true,
               "default": {},
               "title": "Buildargs",
               "type": "object"
            },
            "custom_context": {
               "default": false,
               "title": "Custom Context",
               "type": "boolean"
            },
            "extra_hosts": {
               "additionalProperties": {
                  "type": "string"
               },
               "default": {},
               "title": "Extra Hosts",
               "type": "object"
            },
            "forcerm": {
               "default": false,
               "title": "Forcerm",
               "type": "boolean"
            },
            "isolation": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Isolation"
            },
            "network_mode": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Network Mode"
            },
            "nocache": {
               "default": false,
               "title": "Nocache",
               "type": "boolean"
            },
            "platform": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Platform"
            },
            "pull": {
               "default": false,
               "title": "Pull",
               "type": "boolean"
            },
            "rm": {
               "default": true,
               "title": "Rm",
               "type": "boolean"
            },
            "squash": {
               "default": false,
               "title": "Squash",
               "type": "boolean"
            },
            "tag": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Tag"
            },
            "target": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Target"
            },
            "timeout": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Timeout"
            },
            "use_config_proxy": {
               "default": false,
               "title": "Use Config Proxy",
               "type": "boolean"
            }
         },
         "title": "DockerImageBuildApiOptions",
         "type": "object"
      },
      "ElasticContainerRegistry": {
         "description": "AWS Elastic Container Registry.",
         "properties": {
            "account_id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Account Id"
            },
            "alias": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Alias"
            },
            "public": {
               "default": true,
               "title": "Public",
               "type": "boolean"
            },
            "aws_region": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Aws Region"
            }
         },
         "title": "ElasticContainerRegistry",
         "type": "object"
      },
      "ElasticContainerRegistryRepository": {
         "description": "AWS Elastic Container Registry (ECR) Repository.",
         "properties": {
            "repo_name": {
               "title": "Repo Name",
               "type": "string"
            },
            "registry": {
               "$ref": "#/$defs/ElasticContainerRegistry"
            }
         },
         "required": [
            "repo_name",
            "registry"
         ],
         "title": "ElasticContainerRegistryRepository",
         "type": "object"
      }
   }
}

field ctx: Annotated[CfnginContext | None, Field(alias='context', exclude=True)] = None (alias 'context')
field docker: Annotated[DockerImageBuildApiOptions, Field(validate_default=True)] = DockerImageBuildApiOptions(buildargs={}, custom_context=False, extra_hosts={}, forcerm=False, isolation=None, network_mode=None, nocache=False, platform=None, pull=False, rm=True, squash=False, tag=None, target=None, timeout=None, use_config_proxy=False)

Options for docker image build.

field dockerfile: str = 'Dockerfile'

Path within the build context to the Dockerfile.

field ecr_repo: ElasticContainerRegistryRepository | None = None

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.

field path: DirectoryPath = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/runway/checkouts/stable/docs/source')

Path to the directory containing the Dockerfile.

Constraints:
  • path_type = dir

field repo: Annotated[str | None, Field(validate_default=True)] = None

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

field tags: Annotated[list[str], Field(validate_default=True)] = ['latest']

List of tags to apply to the image.

pydantic model runway.cfngin.hooks.docker.image.ImagePushArgs[source]

Bases: BaseModel

Args passed to image.push.

Show JSON schema
{
   "title": "ImagePushArgs",
   "type": "object",
   "properties": {
      "ctx": {
         "default": null,
         "title": "Ctx"
      },
      "ecr_repo": {
         "anyOf": [
            {
               "$ref": "#/$defs/ElasticContainerRegistryRepository"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "image": {
         "default": null,
         "title": "Image"
      },
      "repo": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Repo"
      },
      "tags": {
         "default": [],
         "items": {
            "type": "string"
         },
         "title": "Tags",
         "type": "array"
      }
   },
   "$defs": {
      "ElasticContainerRegistry": {
         "description": "AWS Elastic Container Registry.",
         "properties": {
            "account_id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Account Id"
            },
            "alias": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Alias"
            },
            "public": {
               "default": true,
               "title": "Public",
               "type": "boolean"
            },
            "aws_region": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Aws Region"
            }
         },
         "title": "ElasticContainerRegistry",
         "type": "object"
      },
      "ElasticContainerRegistryRepository": {
         "description": "AWS Elastic Container Registry (ECR) Repository.",
         "properties": {
            "repo_name": {
               "title": "Repo Name",
               "type": "string"
            },
            "registry": {
               "$ref": "#/$defs/ElasticContainerRegistry"
            }
         },
         "required": [
            "repo_name",
            "registry"
         ],
         "title": "ElasticContainerRegistryRepository",
         "type": "object"
      }
   }
}

field ctx: Annotated[CfnginContext | None, Field(alias='context', exclude=True)] = None (alias 'context')
field ecr_repo: ElasticContainerRegistryRepository | None = None

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.

field image: DockerImage | None = None

Image to push.

field repo: Annotated[str | None, Field(validate_default=True)] = None

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

field tags: Annotated[list[str], Field(validate_default=True)] = []

List of tags to push.

pydantic model runway.cfngin.hooks.docker.image.ImageRemoveArgs[source]

Bases: BaseModel

Args passed to image.remove.

Show JSON schema
{
   "title": "ImageRemoveArgs",
   "type": "object",
   "properties": {
      "ctx": {
         "default": null,
         "title": "Ctx"
      },
      "ecr_repo": {
         "anyOf": [
            {
               "$ref": "#/$defs/ElasticContainerRegistryRepository"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "force": {
         "default": false,
         "title": "Force",
         "type": "boolean"
      },
      "image": {
         "default": null,
         "title": "Image"
      },
      "noprune": {
         "default": false,
         "title": "Noprune",
         "type": "boolean"
      },
      "repo": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Repo"
      },
      "tags": {
         "default": [],
         "items": {
            "type": "string"
         },
         "title": "Tags",
         "type": "array"
      }
   },
   "$defs": {
      "ElasticContainerRegistry": {
         "description": "AWS Elastic Container Registry.",
         "properties": {
            "account_id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Account Id"
            },
            "alias": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Alias"
            },
            "public": {
               "default": true,
               "title": "Public",
               "type": "boolean"
            },
            "aws_region": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Aws Region"
            }
         },
         "title": "ElasticContainerRegistry",
         "type": "object"
      },
      "ElasticContainerRegistryRepository": {
         "description": "AWS Elastic Container Registry (ECR) Repository.",
         "properties": {
            "repo_name": {
               "title": "Repo Name",
               "type": "string"
            },
            "registry": {
               "$ref": "#/$defs/ElasticContainerRegistry"
            }
         },
         "required": [
            "repo_name",
            "registry"
         ],
         "title": "ElasticContainerRegistryRepository",
         "type": "object"
      }
   }
}

field ctx: Annotated[CfnginContext | None, Field(alias='context', exclude=True)] = None (alias 'context')
field ecr_repo: ElasticContainerRegistryRepository | None = None

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.

field force: bool = False

Whether to force the removal of the image.

field image: DockerImage | None = None

Image to push.

field noprune: bool = False

Whether to delete untagged parents.

field repo: Annotated[str | None, Field(validate_default=True)] = None

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

field tags: Annotated[list[str], Field(validate_default=True)] = []

List of tags to apply to the image.

runway.cfngin.hooks.docker.image.build(*, context: runway.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: runway.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: runway.context.CfnginContext, **kwargs: Any) DockerHookData[source]

Docker image push remove.

Replicates the functionality of docker image push CLI command.

kwargs are parsed by ImageRemoveArgs.