Add Docker Hub proxy cache mirror config for buildkit pods

Reads BP_DOCKERHUB_PROXY env var and injects it as a mirror for
  docker.io in the buildkit TOML config. Fixes 504 Gateway Timeout
  on IPv6 clusters that cannot reach registry-1.docker.io directly.
This commit is contained in:
buildpulser 2026-03-11 21:10:23 -07:00
parent 837f59bf50
commit bec8517ed4
3 changed files with 16 additions and 2 deletions

2
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -130,6 +130,20 @@ function addClusterLocalRegistryConfig(buildkitConfig: string): string {
}; };
} }
const dockerhubProxy = process.env.BP_DOCKERHUB_PROXY;
if (dockerhubProxy && dockerhubProxy.length) {
if (!inlineToml['registry']['docker.io']) {
inlineToml['registry']['docker.io'] = {};
}
inlineToml['registry']['docker.io']['mirrors'] = [dockerhubProxy];
if (!inlineToml['registry'][dockerhubProxy]) {
inlineToml['registry'][dockerhubProxy] = {};
}
inlineToml['registry'][dockerhubProxy]['http'] = true;
inlineToml['registry'][dockerhubProxy]['insecure'] = true;
}
return TOML.stringify(inlineToml); return TOML.stringify(inlineToml);
} }