dockerfile

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dockerfile lists the images a Dockerfile build pulls (FROM, COPY --from, RUN --mount from= and the frontend, set by # syntax= or BUILDKIT_SYNTAX), expanded the way BuildKit expands them. The build engine checks them against the config's source policy before buildx runs. Parsing and expansion are BuildKit's own (frontend/dockerfile parser and shell); nothing here builds or pulls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Input

type Input struct {
	// Content is the Dockerfile.
	Content []byte
	// Args are the build args passed to buildx (they override ARG
	// defaults, as --build-arg does).
	Args map[string]string
	// Target, when set, is the stage built; stages it does not depend on
	// are still listed (BuildKit may skip them, but a policy check must
	// not depend on which stage a caller happens to pick).
	Target string
	// Platforms are the os/arch[/variant] targets; references expand once
	// per platform (TARGETARCH and friends), deduplicated.
	Platforms []string
}

Input is one Dockerfile and the build inputs its references expand from.

type Source

type Source struct {
	// Ref is the image reference as BuildKit would resolve it, after
	// build-arg expansion. Empty when Err is set.
	Ref string
	// Instruction names what pulls it: "FROM", "COPY --from",
	// "RUN --mount from", or "syntax" (the frontend image).
	Instruction string
	// Line is the 1-based Dockerfile line (0 for a frontend set through
	// the BUILDKIT_SYNTAX build arg).
	Line int
	// Raw is the reference as written, before expansion.
	Raw string
	// Err explains why the reference could not be resolved to an image
	// (an expansion that yields no valid reference). A caller enforcing a
	// policy must treat it as a rejection: it cannot be proven permitted.
	Err string
}

Source is one image a Dockerfile build pulls.

func Sources

func Sources(in Input) ([]Source, error)

Sources lists every image the Dockerfile pulls: each FROM that is not a prior stage or scratch, each COPY --from and RUN --mount from= naming an image rather than a stage, and the frontend image (# syntax= or the BUILDKIT_SYNTAX build arg). References are expanded the way BuildKit expands them (FROM uses the global ARGs, with build args overriding defaults, plus the automatic platform args; flags use the stage's ARG and ENV), once per platform, deduplicated in first-seen order.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL