Help us shape the future of Go! Take the 2026 Go Developer Survey

dockerfile

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package dockerfile generates a Dockerfile that wraps a devcontainer base image (or upstream Dockerfile) with feature install scripts and a pre-staged VS Code server.

The resulting Dockerfile is a single-stage build that:

  1. FROM the base image (or an intermediate stage produced by an upstream Dockerfile build).
  2. Writes devcontainer-features.builtin.env (_CONTAINER_USER, _REMOTE_USER and their homes) into /tmp/dev-container-features/.
  3. For each feature in install order: sets the feature's containerEnv, COPYs its contents into /tmp/dev-container-features/<safe-id>/ next to its devcontainer-features.env (option values) and install wrapper, and RUNs the wrapper, which exports both env files and runs install.sh (as upstream devcontainers/cli does).
  4. COPY the VS Code server tarball into the canonical ~/.vscode-server/bin/<commit>/ location and unpack it.
  5. Set ENV / USER according to the spec. Like upstream, the base image's WORKDIR is kept.

The generator does not run the build itself; it only emits the Dockerfile bytes plus a list of files that must be present in the build context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(in Inputs) ([]byte, error)

Generate emits the Dockerfile contents.

Types

type Inputs

type Inputs struct {
	// BaseMetadata is the metadata of the FROM image, before features and config.
	BaseMetadata        []metadata.Entry
	Metadata            metadata.CollectOptions
	OmitSyntaxDirective bool
	// Spec is the loaded devcontainer.json.
	Spec *spec.DevContainer
	// BaseImage is the FROM image. May be either the spec's `image`
	// field, or a tag produced by a prior build of the
	// spec's upstream Dockerfile.
	BaseImage string
	// Features in install order, all already staged on disk.
	Features []features.Resolved
	// FeaturesContextDir is the path within the build context that
	// contains the staged feature directories. Each feature is at
	// FeaturesContextDir/<SafeID>.
	FeaturesContextDir string
	// VSCodeServer optionally injects a VS Code server tarball.
	VSCodeServer *vscode.Result
	// VSCodeServerContextPath is the path within the build context to
	// the server tarball (relative to context root).
	VSCodeServerContextPath string
	// RemoteUser overrides the spec's remoteUser. Empty means use the
	// spec's value, falling back to root.
	RemoteUser string
	// ImageUser is the user configured in the base image, restored after
	// installation. Features see it as the container user when the spec
	// sets no containerUser.
	// Empty means root.
	ImageUser string
}

Inputs collects everything the generator needs.

Jump to

Keyboard shortcuts

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