Skip to navigation

nemo_gym.tasks.harbor.dockerfile

View as Markdown

Recognize Dockerfiles that only name a base image.

Many tasks ship a Dockerfile that is FROM <image> plus WORKDIR, ENV, USER or LABEL lines. Nothing in such a file changes the filesystem, so Gym can run the base image directly and apply the recorded settings at sandbox creation instead of building. Anything else (RUN, COPY, ADD, multi-stage builds, ARG-templated images) needs a real build, which is not part of this loader yet.

Module Contents

Classes

NameDescription
BaseImageA Dockerfile that reduces to a base image plus creation-time settings.

Functions

NameDescription
_logical_linesJoin continuations without inventing whitespace; drop comments and blanks.
_parse_env-
base_image_onlyReturn faithfully interpreted settings, or None when a build is needed.

Data

_ALLOWED_INSTRUCTIONS

_ENV_KEY

API

class nemo_gym.tasks.harbor.dockerfile.BaseImage(
image: str,
workdir: str | None = None,
env: dict[str, str] = dict(),
user: str | None = None
)
Dataclass

A Dockerfile that reduces to a base image plus creation-time settings.

env
dict[str, str] = field(default_factory=dict)
image
str
user
str | None = None
workdir
str | None = None
nemo_gym.tasks.harbor.dockerfile._logical_lines(
text: str
) -> list[str]

Join continuations without inventing whitespace; drop comments and blanks.

nemo_gym.tasks.harbor.dockerfile._parse_env(
arguments: str
) -> dict[str, str] | None
nemo_gym.tasks.harbor.dockerfile.base_image_only(
text: str

Return faithfully interpreted settings, or None when a build is needed.

Variable expansion and relative working directories depend on the base image’s configuration. Leave those to a real build until that configuration is available.

nemo_gym.tasks.harbor.dockerfile._ALLOWED_INSTRUCTIONS = {'FROM', 'WORKDIR', 'ENV', 'USER', 'LABEL'}
nemo_gym.tasks.harbor.dockerfile._ENV_KEY = re.compile('[A-Za-z_][A-Za-z0-9_]*')