Skip to content

Makefile: use linuxkit env vars for org and builder config#5700

Open
europaul wants to merge 2 commits intolf-edge:masterfrom
europaul:linuxkit-env-vars
Open

Makefile: use linuxkit env vars for org and builder config#5700
europaul wants to merge 2 commits intolf-edge:masterfrom
europaul:linuxkit-env-vars

Conversation

@europaul
Copy link
Contributor

@europaul europaul commented Mar 24, 2026

Description

Supersedes #5669, depends on #5699.

Adopt linuxkit's native environment variable support for registry and
builder configuration, removing the Makefile-level workarounds that
threaded flags through every linuxkit call site.

Removed:

  • BUILDKIT_CONFIG_FILE / BUILDKIT_CONFIG_OPTS variables and the manifest-mode guard
  • LINUXKIT_ORG_TARGET variable and its injection at 9 call sites
  • REGISTRY make variable (was only used to feed LINUXKIT_ORG_TARGET)

New interface — set in the runner environment or on the make command line:

Purpose Old New
Custom push registry make REGISTRY=myregistry LINUXKIT_PKG_ORG=myregistry/lfedge make
buildkit registry mirrors BUILDKIT_CONFIG_FILE=/etc/buildkit/buildkitd.toml (auto-detected) LINUXKIT_BUILDER_CONFIG=/path/to/buildkitd.toml (explicit)
Pull-side registry mirrors not supported LINUXKIT_MIRROR=docker.io=http://my-mirror.local

LINUXKIT_BUILDER_CONFIG defaults to /etc/buildkit/buildkitd.toml if the file exists, matching previous behavior.

Updates docs/BUILD.md to document LINUXKIT_PKG_ORG and LINUXKIT_MIRROR usage for local registries and pull-through proxies.

How to test and validate this PR

  1. Normal build — make without any overrides should behave identically to before.
  2. Custom registry — LINUXKIT_PKG_ORG=myregistry/lfedge make should tag/push packages to myregistry/lfedge/*.
  3. buildkit mirror — set LINUXKIT_BUILDER_CONFIG=/etc/buildkit/buildkitd.toml on a runner that has the file; verify buildkit uses the mirror config.

Changelog notes

No user-facing changes. Build tooling simplification: linuxkit registry mirror and org configuration is now passed via environment variables (LINUXKIT_BUILDER_CONFIG, LINUXKIT_PKG_ORG, LINUXKIT_MIRROR) instead of make variables, making CI runner configuration more transparent.

PR Backports

  • 16.0-stable: Yes
  • 14.5-stable: Yes
  • 13.4-stable: Yes

Checklist

  • I've provided a proper description
  • I've added the proper documentation
  • I've tested my PR on amd64 device
  • I've tested my PR on arm64 device
  • I've written the test verification instructions
  • I've set the proper labels to this PR
  • I've checked the boxes above, or I've provided a good reason why I didn't check them.

Introduce mk/linuxkit.mk (included from the top-level Makefile) to
consolidate all linuxkit build logic in one place and support three
acquisition modes, selected in priority order:

  1. LINUXKIT_SRC=/path   — build from a local source tree; make
                            tracks Go source changes as dependencies.
  2. LINUXKIT_GIT_URL set — clone at LINUXKIT_GIT_REF (commit hash)
                            and build the binary.
  3. (neither)            — download the upstream release binary.

Mode 2 requires a commit hash (not a branch name) for reproducibility.
The hash is used directly as the versioned binary name — no network
call at parse time.  Make skips the recipe if the binary already
exists (cached).  Use git ls-remote to update the pinned hash.

Defaults to upstream linuxkit at the current master tip:
  LINUXKIT_GIT_URL = https://github.com/linuxkit/linuxkit
  LINUXKIT_GIT_REF = 4cfb70d3cc9256024bb0d4de760c631df0ad06f6
Set LINUXKIT_GIT_URL="" to revert to the release download (mode 3).

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
@europaul europaul requested a review from eriknordmark as a code owner March 24, 2026 14:25
@rene
Copy link
Contributor

rene commented Mar 24, 2026

@rucoder , please, close #5669 since it's replaced by this one.

docs/BUILD.md Outdated
EVE's build system allows to override the default docker registry through the `REGISTRY` variable. For example:
EVE's build system provides two environment variables for this:

- `LINUXKIT_PKG_ORG` — overrides the registry organization used for pushing and pulling package images.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, fix Yetus errors

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

linuxkit now supports environment variables for flags previously
threaded through every linuxkit call site in this Makefile.

Remove LINUXKIT_ORG_TARGET and BUILDKIT_CONFIG_OPTS workarounds:
- Drop BUILDKIT_CONFIG_FILE / BUILDKIT_CONFIG_OPTS variables and the
  manifest-mode guard; replace with LINUXKIT_BUILDER_CONFIG env var
  which defaults to /etc/buildkit/buildkitd.toml if the file exists
- Drop LINUXKIT_ORG_TARGET from all linuxkit call sites (9 locations)
- Drop REGISTRY make variable; use LINUXKIT_PKG_ORG directly

Update docs/BUILD.md to document the new variables:
- LINUXKIT_PKG_ORG for pushing to a custom registry
- LINUXKIT_MIRROR for pull-through proxy configuration

Migration:
  make REGISTRY=myregistry  ->  LINUXKIT_PKG_ORG=myregistry/lfedge make

For buildkit registry mirrors, LINUXKIT_BUILDER_CONFIG auto-detects
/etc/buildkit/buildkitd.toml as before; override by setting
LINUXKIT_BUILDER_CONFIG explicitly in the environment.
For pull-side mirrors, set LINUXKIT_MIRROR in the runner environment.

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
Signed-off-by: Paul Gaiduk <paulg@zededa.com>
@europaul europaul force-pushed the linuxkit-env-vars branch from 754d81d to 39d43d5 Compare March 24, 2026 14:38
@rucoder
Copy link
Contributor

rucoder commented Mar 24, 2026

@europaul @rene idk why you did it this way, probably to move things faster, but let it be so. :) and we must back-port all these LK related PRs. we must fix CI for all stab;e branches

@europaul
Copy link
Contributor Author

@rucoder yes, just to move faster - this will spare us trying to publish every PR individually from master and STILL failing due to 429, but blocking runners at the same time.

Let's backport once we verify that this fix actually works

@rucoder rucoder added the stable Should be backported to stable release(s) label Mar 24, 2026
@@ -0,0 +1,78 @@
# Copyright (c) 2026 Zededa, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't make much sense to create a folder for only one file. Are you planning to migrate other .mk files to this folder? If so, ok. Otherwise, please, remove it from the folder and just let in the root of the repo, like the kernel ones....

To speed up builds by caching upstream images locally, use `LINUXKIT_MIRROR` to point at a pull-through registry mirror:

```sh
make LINUXKIT_MIRROR="http://localhost:5001" pkgs eve
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this syntax correct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rene yes, correct. by default we override docker.io AFAIR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it is better to specify a full syntax of-course like here linuxkit/linuxkit#4205

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codecov
Copy link

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 29.45%. Comparing base (2281599) to head (39d43d5).
⚠️ Report is 350 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5700      +/-   ##
==========================================
+ Coverage   19.52%   29.45%   +9.92%     
==========================================
  Files          19       18       -1     
  Lines        3021     2417     -604     
==========================================
+ Hits          590      712     +122     
+ Misses       2310     1554     -756     
- Partials      121      151      +30     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stable Should be backported to stable release(s)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants