Skip to main content

expand_dockerfile

Function expand_dockerfile 

Source
pub fn expand_dockerfile(
    df: &Dockerfile,
    build_args: &HashMap<String, String>,
) -> Dockerfile
Expand description

Expand Docker build-time variables across an entire Dockerfile IR.

Walks global_args first (pre-FROM ARG defaults), then each Stage’s instructions, maintaining the accumulating ARG/ENV binding map exactly as the buildah CLI loop does: ARG scope is per-stage (reset to build_args + global ARG defaults at the start of each stage), and ARG/ENV instructions fold their (expanded) values into the bindings so later instructions observe them.

Substituted fields match backend::buildah::expand_instruction — RUN command, ENV values, COPY/ADD src+dest, WORKDIR, USER, LABEL values — PLUS each value in RunInstruction::env (the per-step transient env), which the inline translator historically failed to expand.

Returns a fully-substituted clone of the IR; the input is not modified.