docker_pkg.builder

Workflow to process, build and publish image definitions

Classes

DockerBuilder(directory, config[, ...])

Scans the filesystem for image declarations, and build them

ImageFSM(root, client, config[, nocache, pull])

Finite state machine

class docker_pkg.builder.ImageFSM(root: str, client: DockerClient, config: Dict, nocache: bool = True, pull: bool = True)[source]

Bases: object

Finite state machine

STATE_PUBLISHED = 'published'

Image is in the target Docker registry

STATE_VERIFIED = 'verified'

Image has been verified.

STATE_BUILT = 'built'

Image is in the local Docker daemon

STATE_TO_BUILD = 'to_build'

Image could not be found in the registry or the daemon

STATE_ERROR = 'error'

Error state, for examples a failure to build locally or to publish it to the registry

STATES = ['published', 'built', 'to_build', 'verified', 'error']

List of possible states

property label: str

The full label of the image, $registry/$ns/$name:$tag

property name: str

The image full name, $registry/$ns/$name

build()[source]

Build the image

verify()[source]

Verify the image.

publish()[source]

Publish the image

add_child(img: ImageFSM)[source]

Declare another image as child of the current one

all_children() List[ImageFSM][source]

Report all images that are born of the current one.

The result will include the current image, and all of their direct and indirect children. No logical loop protection is present here, nor the ordering is guaranteed in any ways.

Returns: (list) A list of all images that include the current one.

class docker_pkg.builder.DockerBuilder(directory: str, config: Dict[str, Any], selection: Optional[str] = None, nocache: bool = True, pull: bool = True)[source]

Bases: object

Scans the filesystem for image declarations, and build them

scan(max_workers: int = 1)[source]

Scan the desired directory for dockerfiles, add them all to a build chain

max_workers: maximum number of threads to use when scanning local definition of images. For each image found, scan triggers queries to the local Docker daemon and the registry. Passed to concurrent.futures.ThreadPoolExecutor(). Default: 1.

images_in_state(state: str) List[ImageFSM][source]

Find all images in a specific state

property build_chain: List[ImageFSM]
prune_chain() List[ImageFSM][source]

Returns the images that need to be pruned, in the correct order.

pull_dependencies(fsm: ImageFSM)[source]

Pulls all dependencies from the docker registry, if they’re present

images_to_update() Set[ImageFSM][source]

Returns a list of images to update

update_images(images: Set[ImageFSM], reason: str, baseimg: str, version: Optional[str] = None)[source]

Update the changelog for the images provided

build() Generator[ImageFSM, None, None][source]

Build the images in the build chain

publish() Generator[ImageFSM, None, None][source]

Publish all images to the configured registry