Skip to content

Latest commit

 

History

History
195 lines (111 loc) · 6.06 KB

universal_build.helpers.build_docker.md

File metadata and controls

195 lines (111 loc) · 6.06 KB

module universal_build.helpers.build_docker

Utilities to help building Docker images.

Global Variables

  • FLAG_DOCKER_IMAGE_PREFIX

function parse_arguments

parse_arguments(
    input_args: List[str] = None,
    argument_parser: ArgumentParser = None
) → dict

Parses all arguments and returns a sanitized & augmented list of arguments.

Sanitized means that, for example, the version is already checked and set depending on our build guidelines. If arguments are not valid, exit the script run.

Args:

  • input_args (List[str], optional): List of arguments that are used instead of the arguments passed to the process. Defaults to None.
  • argument_parser (arparse.ArgumentParser, optional): An argument parser which is passed as a parents parser to the default ArgumentParser to be able to use additional flags besides the default ones.

Returns:

  • dict: The parsed default arguments thar are already checked for validity.

function check_image

check_image(
    image: str,
    trivy: bool = True,
    exit_on_error: bool = True
) → CompletedProcess

Run vulnerability checks on Dockerimage.

Args:

  • image (str): The name of the docker image to check.
  • trivy (bool, optional): Activate trivy vulnerability check. Defaults to True.
  • exit_on_error (bool, optional): If True, exit process as soon as an error occurs.

function lint_dockerfile

lint_dockerfile(
    hadolint: bool = True,
    dockerfile: str = 'Dockerfile',
    exit_on_error: bool = True
) → None

Run hadolint on the Dockerfile.

Args:

  • hadolint (bool, optional): Activate hadolint dockerfile linter. Defaults to True.
  • dockerfile (str, optional): Specify a specific Dockerfile. If not specified, the default Dockerfile wil be used.
  • exit_on_error (bool, optional): Exit process if an error occurs. Defaults to True.

function get_image_name

get_image_name(name: str, tag: str, image_prefix: str = '') → str

Get a valid versioned image name.

Args:

  • name (str): Name of the docker image.
  • tag (str): Version to use for the tag.
  • image_prefix (str, optional): The prefix added to the name to indicate an organization on DockerHub or a completely different repository.

Returns:

  • str: a valid docker image name based on: prefix/name:tag

function build_docker_image

build_docker_image(
    name: str,
    version: str,
    build_args: str = '',
    docker_image_prefix: str = '',
    dockerfile: Optional[str] = None,
    additional_build_args: str = '',
    exit_on_error: bool = True
) → CompletedProcess

Build a docker image from a Dockerfile in the working directory.

Args:

  • name (str): Name of the docker image.
  • version (str): Version to use as tag.
  • build_args (str, optional): Add additional build arguments for docker build.
  • docker_image_prefix (str, optional): The prefix added to the name to indicate an organization on DockerHub or a completely different repository.
  • dockerfile (str, optional): Specify a specific Dockerfile. If not specified, the default Dockerfile wil be used.
  • exit_on_error (bool, optional): If True, exit process as soon as an error occurs.

Returns:

  • subprocess.CompletedProcess: Returns the CompletedProcess object of the

function release_docker_image

release_docker_image(
    name: str,
    version: str,
    docker_image_prefix: str,
    exit_on_error: bool = True
) → CompletedProcess

Push a Docker image to a repository.

Args:

  • name (str): The name of the image. Must not be prefixed!
  • version (str): The tag used for the image.
  • docker_image_prefix (str): The prefix added to the name to indicate an organization on DockerHub or a completely different repository.
  • exit_on_error (bool, optional): Exit process if an error occurs. Defaults to True.

Returns:

  • subprocess.CompletedProcess: Returns the CompletedProcess object of the docker push ... command.

This file was automatically generated via lazydocs.