Skip to content

Commit f2d1e33

Browse files
committed
history: finalize when exporting
Signed-off-by: CrazyMax <[email protected]>
1 parent ee9866a commit f2d1e33

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/buildx/history.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,11 @@ export class History {
105105
return await this.exportLegacy(builderName, nodeName, refs, outDir, opts.image);
106106
}
107107

108-
// wait 3 seconds to ensure build records are finalized: https://github.com/moby/buildkit/pull/5109
109-
await Util.sleep(3);
108+
if (await this.buildx.versionSatisfies('>=0.24.0')) {
109+
// wait 3 seconds to ensure build records are finalized: https://github.com/moby/buildkit/pull/5109
110+
// not necessary since buildx 0.24.0: https://github.com/docker/buildx/pull/3152
111+
await Util.sleep(3);
112+
}
110113

111114
const summaries: Summaries = {};
112115
if (!opts.noSummaries) {
@@ -138,7 +141,12 @@ export class History {
138141

139142
const dockerbuildPath = path.join(outDir, `${History.exportFilename(refs)}.dockerbuild`);
140143

141-
const cmd = await this.getExportCommand(['--builder', builderName, '--output', dockerbuildPath, ...refs]);
144+
const exportArgs = ['--builder', builderName, '--output', dockerbuildPath, ...refs];
145+
if (await this.buildx.versionSatisfies('>=0.24.0')) {
146+
exportArgs.push('--finalize');
147+
}
148+
149+
const cmd = await this.getExportCommand(exportArgs);
142150
await Exec.getExecOutput(cmd.command, cmd.args);
143151

144152
const dockerbuildStats = fs.statSync(dockerbuildPath);

0 commit comments

Comments
 (0)