Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

68 changes: 43 additions & 25 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,15 +640,26 @@ void actionsToolkit.run(
}
});

// Print Docker info
await core.group(`Docker info`, async () => {
try {
await Docker.printVersion();
await Docker.printInfo();
} catch (e) {
core.info((e as Error).message);
}
});
const printDockerInfo = () =>
core.group(`Docker info`, async () => {
try {
await Docker.printVersion();
await Docker.printInfo();
} catch (e) {
core.info((e as Error).message);
}
});

// The first Docker command waits for the daemon to finish starting, which
// takes most of a second on a fresh VM. Start that wait now so it overlaps
// buildx setup and the builder start, and print Docker info after them.
// BLACKSMITH_DOCKER_WARMUP=false keeps the old order.
let dockerWarmup: Promise<unknown> | null = null;
if (process.env.BLACKSMITH_DOCKER_WARMUP === "false") {
await printDockerInfo();
} else {
dockerWarmup = execAsync("docker version").catch(() => undefined);
}

// Validate and setup buildx version
let buildxVersion = DEFAULT_BUILDX_VERSION;
Expand All @@ -664,26 +675,33 @@ void actionsToolkit.run(
}
}

// Setup buildx
await core.group(`Setup buildx`, async () => {
await setupBuildx(buildxVersion, toolkit);

if (!(await toolkit.buildx.isAvailable())) {
core.setFailed(
`Docker buildx is required. See https://github.com/docker/setup-buildx-action to set up buildx.`,
);
return;
}
});

// Start Blacksmith builder
let builderInfo: { addr: string | null; exposeId: string } = {
addr: null,
exposeId: "",
};
await core.group(`Starting Blacksmith builder`, async () => {
builderInfo = await startBlacksmithBuilder(inputs);
});
try {
// Setup buildx
await core.group(`Setup buildx`, async () => {
await setupBuildx(buildxVersion, toolkit);

if (!(await toolkit.buildx.isAvailable())) {
core.setFailed(
`Docker buildx is required. See https://github.com/docker/setup-buildx-action to set up buildx.`,
);
return;
}
});

// Start Blacksmith builder
await core.group(`Starting Blacksmith builder`, async () => {
builderInfo = await startBlacksmithBuilder(inputs);
});
} finally {
if (dockerWarmup) {
await dockerWarmup;
await printDockerInfo();
}
}

if (builderInfo.addr) {
// Create and configure the builder
Expand Down
2 changes: 1 addition & 1 deletion src/setup_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export async function startBuildkitd(
// Wait for buildkitd PID to appear with backoff retry
const startTime = Date.now();
const timeout = 10000; // 10 seconds
const backoff = 300; // 300ms
const backoff = 50; // 50ms

while (Date.now() - startTime < timeout) {
try {
Expand Down
Loading