docker-compose: fix loading buildx plugin (#468812)

This commit is contained in:
Sandro
2025-12-14 02:43:18 +00:00
committed by GitHub
3 changed files with 45 additions and 10 deletions
@@ -0,0 +1,31 @@
diff --git a/cli-plugins/manager/manager_unix.go b/cli-plugins/manager/manager_unix.go
index f546dc3849..5e3ae08dbc 100644
--- a/cli-plugins/manager/manager_unix.go
+++ b/cli-plugins/manager/manager_unix.go
@@ -2,6 +2,11 @@
package manager
+import (
+ "os"
+ "path/filepath"
+)
+
// defaultSystemPluginDirs are the platform-specific locations to search
// for plugins in order of preference.
//
@@ -12,9 +17,8 @@
// 3. Platform-specific defaultSystemPluginDirs (as defined below).
//
// [ConfigFile.CLIPluginsExtraDirs]: https://pkg.go.dev/github.com/docker/cli@v26.1.4+incompatible/cli/config/configfile#ConfigFile.CLIPluginsExtraDirs
-var defaultSystemPluginDirs = []string{
- "/usr/local/lib/docker/cli-plugins",
- "/usr/local/libexec/docker/cli-plugins",
- "/usr/lib/docker/cli-plugins",
- "/usr/libexec/docker/cli-plugins",
+var defaultSystemPluginDirs []string
+
+func init() {
+ defaultSystemPluginDirs = filepath.SplitList(os.Getenv("DOCKER_CLI_PLUGIN_DIRS"))
}
@@ -15,7 +15,11 @@ buildGoModule rec {
hash = "sha256-7g9l9SBxPY3jMS3DWZNI/fhOZN1oZo1qkUfhMfbzAaM=";
};
vendorHash = "sha256-COfB0MLBMOfTdLbpShBkMOEule/1cu6Bo5lm1ieO/nA=";
vendorHash = "sha256-EFbEd1UwrBnH6pSh+MvupYdie8SnKr8y6K9lQflBSlk=";
modPostBuild = ''
patch -d vendor/github.com/docker/cli/ -p1 < ${./cli-system-plugin-dir-from-env.patch}
'';
ldflags = [
"-X github.com/docker/compose/v2/internal.Version=${version}"
@@ -258,10 +258,9 @@ let
++ lib.optionals sbomSupport [ docker-sbom ]
++ lib.optionals initSupport [ docker-init ];
pluginsRef = symlinkJoin {
name = "docker-plugins";
paths = plugins;
};
dockerCliPluginsDirs = lib.strings.concatStringsSep ":" (
map (p: "${p}/libexec/docker/cli-plugins") plugins
);
in
buildGoModule (
{
@@ -277,6 +276,10 @@ let
hash = cliHash;
};
patches = [
./cli-system-plugin-dir-from-env.patch
];
vendorHash = null;
nativeBuildInputs = [
@@ -298,10 +301,6 @@ let
postPatch = ''
patchShebangs man scripts/build/
substituteInPlace ./scripts/build/.variables --replace-fail "set -eu" ""
''
+ lib.optionalString (plugins != [ ]) ''
substituteInPlace ./cli-plugins/manager/manager_unix.go --replace-fail /usr/libexec/docker/cli-plugins \
"${pluginsRef}/libexec/docker/cli-plugins"
'';
# Keep eyes on BUILDTIME format - https://github.com/docker/cli/blob/${version}/scripts/build/.variables
@@ -330,7 +329,8 @@ let
install -Dm755 ./build/docker $out/libexec/docker/docker
makeWrapper $out/libexec/docker/docker $out/bin/docker \
--prefix PATH : "$out/libexec/docker:$extraPath"
--prefix PATH : "$out/libexec/docker:$extraPath" \
--prefix DOCKER_CLI_PLUGIN_DIRS : "${dockerCliPluginsDirs}"
''
+ lib.optionalString (!clientOnly) ''
# symlink docker daemon to docker cli derivation