mirror of
https://github.com/docker/setup-buildx-action
synced 2026-09-16 16:40:25 +00:00
Merge pull request #609 from crazy-max/pull-buildkit-image-before-create
pull BuildKit image before builder creation
This commit is contained in:
+82
-82
File diff suppressed because one or more lines are too long
+3
-3
File diff suppressed because one or more lines are too long
+36
-4
@@ -124,9 +124,33 @@ actionsToolkit.run(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let builderExists = false;
|
||||||
|
if (inputs.driver !== 'docker') {
|
||||||
|
builderExists = await toolkit.builder.exists(inputs.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
const appendNodes = inputs.append ? (yaml.load(inputs.append) as Node[]) : [];
|
||||||
|
|
||||||
|
if (!standalone && inputs.driver == 'docker-container') {
|
||||||
|
const buildkitImages = new Set<string>();
|
||||||
|
if (!builderExists) {
|
||||||
|
buildkitImages.add(resolveBuildKitImage(inputs.driverOpts));
|
||||||
|
}
|
||||||
|
for (const node of appendNodes) {
|
||||||
|
buildkitImages.add(resolveBuildKitImage(node['driver-opts']));
|
||||||
|
}
|
||||||
|
if (buildkitImages.size > 0) {
|
||||||
|
await core.group(`Pulling BuildKit image(s)`, async () => {
|
||||||
|
for (const image of buildkitImages) {
|
||||||
|
await Docker.pull(image);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (inputs.driver !== 'docker') {
|
if (inputs.driver !== 'docker') {
|
||||||
await core.group(`Creating a new builder instance`, async () => {
|
await core.group(`Creating a new builder instance`, async () => {
|
||||||
if (await toolkit.builder.exists(inputs.name)) {
|
if (builderExists) {
|
||||||
core.info(`Builder ${inputs.name} already exists, skipping creation`);
|
core.info(`Builder ${inputs.name} already exists, skipping creation`);
|
||||||
} else {
|
} else {
|
||||||
const certsDriverOpts = Buildx.resolveCertsDriverOpts(inputs.driver, inputs.endpoint, {
|
const certsDriverOpts = Buildx.resolveCertsDriverOpts(inputs.driver, inputs.endpoint, {
|
||||||
@@ -149,11 +173,10 @@ actionsToolkit.run(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputs.append) {
|
if (appendNodes.length > 0) {
|
||||||
await core.group(`Appending node(s) to builder`, async () => {
|
await core.group(`Appending node(s) to builder`, async () => {
|
||||||
let nodeIndex = 1;
|
let nodeIndex = 1;
|
||||||
const nodes = yaml.load(inputs.append) as Node[];
|
for (const node of appendNodes) {
|
||||||
for (const node of nodes) {
|
|
||||||
const certsDriverOpts = Buildx.resolveCertsDriverOpts(inputs.driver, `${node.endpoint}`, {
|
const certsDriverOpts = Buildx.resolveCertsDriverOpts(inputs.driver, `${node.endpoint}`, {
|
||||||
cacert: process.env[`${context.builderNodeEnvPrefix}_${nodeIndex}_AUTH_TLS_CACERT`],
|
cacert: process.env[`${context.builderNodeEnvPrefix}_${nodeIndex}_AUTH_TLS_CACERT`],
|
||||||
cert: process.env[`${context.builderNodeEnvPrefix}_${nodeIndex}_AUTH_TLS_CERT`],
|
cert: process.env[`${context.builderNodeEnvPrefix}_${nodeIndex}_AUTH_TLS_CERT`],
|
||||||
@@ -274,3 +297,12 @@ actionsToolkit.run(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function resolveBuildKitImage(driverOpts: string[] = []): string {
|
||||||
|
return (
|
||||||
|
driverOpts
|
||||||
|
.find(driverOpt => driverOpt.trim().startsWith('image='))
|
||||||
|
?.trim()
|
||||||
|
.substring('image='.length) || 'moby/buildkit:buildx-stable-1'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user