Skip to content

pkg build: add env var support for mirror, org, builder image and config#4205

Merged
justincormack merged 1 commit intolinuxkit:masterfrom
rucoder:rucoder/env-vars-for-ci
Mar 12, 2026
Merged

pkg build: add env var support for mirror, org, builder image and config#4205
justincormack merged 1 commit intolinuxkit:masterfrom
rucoder:rucoder/env-vars-for-ci

Conversation

@rucoder
Copy link
Copy Markdown
Contributor

@rucoder rucoder commented Mar 12, 2026

Summary

Adds environment variable equivalents for four flags that are commonly needed when running linuxkit on CI/CD self-hosted runners with private registry mirrors, so callers (e.g. make in downstream projects) don't need to be modified to pass these flags explicitly.

Env var Equivalent flag Scope
LINUXKIT_MIRROR --mirror All commands
LINUXKIT_PKG_ORG --org pkg subcommands
LINUXKIT_BUILDER_IMAGE --builder-image pkg build
LINUXKIT_BUILDER_CONFIG --builder-config pkg build

Priority: CLI flag > env var > built-in default (consistent with existing LINUXKIT_CACHE, LINUXKIT_BUILDER_NAME, LINUXKIT_BUILDERS).

LINUXKIT_MIRROR accepts the same format as --mirror ([registry=]url), as a space- or comma-separated list. Env var entries are prepended to CLI-provided entries so that the final SetProxy call for a given registry key comes from the CLI flag, giving it precedence.

LINUXKIT_BUILDER_IMAGE and LINUXKIT_BUILDER_CONFIG use the existing flagOverEnvVarOverDefaultString helper (same pattern as LINUXKIT_BUILDER_NAME).

Test plan

  • go build ./... passes
  • go test -mod=vendor ./... passes (all existing tests green)
  • Set LINUXKIT_MIRROR=docker.io=http://mymirror and verify linuxkit routes pulls through the mirror
  • Set LINUXKIT_PKG_ORG=myorg and verify linuxkit pkg show-tag reflects the org override
  • Set LINUXKIT_BUILDER_IMAGE and verify the builder container uses the specified image
  • Verify CLI flags override the env vars when both are set

🤖 Generated with Claude Code

Introduce environment variables for key CI/CD flags so that self-hosted
runners (e.g. GitHub Actions) can configure registry mirrors and push
targets without modifying calling Makefiles:

- LINUXKIT_MIRROR         - equivalent to --mirror (space/comma-separated);
                            CLI flags take precedence (last SetProxy wins)
- LINUXKIT_PKG_ORG        - equivalent to --org for all pkg subcommands
- LINUXKIT_BUILDER_IMAGE  - equivalent to --builder-image
- LINUXKIT_BUILDER_CONFIG - equivalent to --builder-config

All env var constants are consolidated in pkg_build.go alongside the
existing LINUXKIT_CACHE, LINUXKIT_BUILDER_NAME, LINUXKIT_BUILDERS.

Priority for all: CLI flag > env var > built-in default

Adds a new Environment Variables section to docs/packages.md with a
reference table covering all LINUXKIT_* vars and a note explaining the
two-layer mirror configuration required in CI (linuxkit pulls vs
buildkit Dockerfile pulls).

Signed-off-by: Roman Shaposhnik <[email protected]>
Signed-off-by: Mikhail Malyshev <[email protected]>
@justincormack justincormack merged commit bdef7e8 into linuxkit:master Mar 12, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants