deps_rocker.simple_rocker_extension

Classes

SimpleRockerExtensionMeta

Use a metaclass to dynamically create the static register_argument() function based on the class name and docstring

SimpleRockerExtension

A class to take care of most of the boilerplace required for a rocker extension

Functions

get_workspace_path(→ pathlib.Path)

Get the workspace directory path.

Module Contents

deps_rocker.simple_rocker_extension.get_workspace_path() pathlib.Path

Get the workspace directory path.

Returns the current working directory where rocker is invoked. This is typically where the user’s project files are located.

Returns:

The workspace directory path

Return type:

Path

class deps_rocker.simple_rocker_extension.SimpleRockerExtensionMeta

Bases: type

Use a metaclass to dynamically create the static register_argument() function based on the class name and docstring

class deps_rocker.simple_rocker_extension.SimpleRockerExtension

Bases: rocker.extensions.RockerExtension

A class to take care of most of the boilerplace required for a rocker extension

property builder_output_dir
property builder_stage
_with_builder_defaults(raw: dict) dict
property empy_args_with_builder
property empy_builder_args_with_builder
name = 'simple_rocker_extension'
empy_args
empy_user_args
property empy_builder_args
depends_on_extension: tuple[str, Ellipsis] = ()
apt_packages: list[str] = []
builder_apt_packages: list[str] = []
builder_output_root = '/opt/deps_rocker'
classmethod get_name() str
_get_pkg()
get_snippet(cliargs) str

Get a dockerfile snippet to be executed as ROOT.

get_user_snippet(cliargs) str

Get a dockerfile snippet to be executed after switchingto the expected USER.

get_preamble(cliargs)
get_builder_snippet(cliargs) str
get_and_expand_empy_template(cliargs, empy_args=None, snippet_prefix='')

Loads and expands an empy template snippet for Dockerfile generation. :param empy_args: Arguments to expand in the template :param snippet_prefix: Prefix for the snippet name (default: “”)

Returns:

Expanded template string or empty string if not found/error

_log_empy_template_error(snippet_name, e)
_build_template_args(cliargs, empy_args=None) dict
get_builder_stage_name() str
get_builder_output_dir() str
static register_arguments(parser: argparse.ArgumentParser, defaults: dict = None)

This gets dynamically defined by the metaclass

get_config_file(path: str) bytes | None
static register_arguments_helper(class_type: Type, parser: argparse.ArgumentParser, defaults: dict = None) None

Registers arguments for a given class type to an ArgumentParser instance.

Parameters:
  • class_type (Type) – The class whose name and docstring are used to define the argument. The class must have a name attribute (str) and a docstring.

  • parser (ArgumentParser) – The argparse.ArgumentParser object to which the argument is added.

  • defaults (dict) – A dictionary of default values for the arguments. If None, defaults to an empty dictionary.

Returns:

This method does not return any value. It modifies the parser in place.

Return type:

None

Raises:

AttributeError – If the class_type does not have a name attribute.

invoke_after(cliargs: dict) set[str]

Returns a set of extensions that this extension should be invoked after. For SimpleRockerExtension, this returns the dependencies.

required(cliargs: dict) set[str]

Returns a set of dependencies required by this extension. If deps is defined, returns it as a set.

get_workspace_path
static get_apt_command(packages: list[str], use_cache_mount: bool = None) str

Generate an apt install command with optional cache mount for BuildKit.

Parameters:
  • packages – List of apt packages to install

  • use_cache_mount – Whether to use BuildKit cache mounts (None=auto-detect, True=force, False=disable)

Returns:

Complete RUN command string for Dockerfile