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, client, config, nocache=True, pull=True)[source]

Bases: object

Finite state machine

STATE_PUBLISHED = 'published'

Image is in the target Docker registry

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', 'error']

List of possible states

label
name
build()[source]

Build the image

add_tag(tag)[source]
publish()[source]

Publish the image

add_child(img)[source]

Declare another image as child of the current one

all_children()[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, config, selection=None, nocache=True, pull=True)[source]

Bases: object

Scans the filesystem for image declarations, and build them

scan(max_workers=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)[source]

Find all images in a specific state

build_chain
prune_chain()[source]

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

pull_dependencies(fsm)[source]

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

images_to_update()[source]

Returns a list of images to update

update_images(images, reason, baseimg, version=None)[source]
build()[source]

Build the images in the build chain

publish()[source]

Publish all images to the configured registry