Skip to content

Commit 827b46c

Browse files
authored
Show image download progress during builds (#850)
- Closes #710. ## Type of Change - [ ] Bug fix - [x] New feature - [ ] Breaking change - [ ] Documentation update ## Motivation and Context Fetching images during builds currently show just a 0.0s timer, and no other info making builds appear hung. This adds a realtime download progress bar with info, when pulling base images during builds. <img width="1133" height="640" alt="Screenshot 2025-11-04 at 2 54 33 PM" src="https://github.com/user-attachments/assets/200d8485-a956-4ce1-bbfe-d7406bd85774" /> ## Testing - [x] Tested locally - [ ] Added/updated tests - [ ] Added/updated docs
1 parent 8685bb2 commit 827b46c

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

Sources/ContainerBuild/BuildImageResolver.swift

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,17 @@ import ContainerizationOCI
2020
import Foundation
2121
import GRPC
2222
import Logging
23+
import TerminalProgress
2324

2425
struct BuildImageResolver: BuildPipelineHandler {
2526
let contentStore: ContentStore
27+
let quiet: Bool
28+
let output: FileHandle
2629

27-
public init(_ contentStore: ContentStore) throws {
30+
public init(_ contentStore: ContentStore, quiet: Bool = false, output: FileHandle = FileHandle.standardError) throws {
2831
self.contentStore = contentStore
32+
self.quiet = quiet
33+
self.output = output
2934
}
3035

3136
func accept(_ packet: ServerStream) throws -> Bool {
@@ -54,8 +59,21 @@ struct BuildImageResolver: BuildPipelineHandler {
5459
}
5560

5661
let img = try await {
57-
guard let img = try? await ClientImage.pull(reference: ref, platform: platform) else {
58-
return try await ClientImage.fetch(reference: ref, platform: platform)
62+
let progressConfig = try ProgressConfig(
63+
terminal: self.output,
64+
description: "Pulling \(ref)",
65+
showPercent: true,
66+
showProgressBar: true,
67+
showSize: true,
68+
showSpeed: true,
69+
disableProgressUpdates: self.quiet
70+
)
71+
let progress = ProgressBar(config: progressConfig)
72+
defer { progress.finish() }
73+
progress.start()
74+
75+
guard let img = try? await ClientImage.pull(reference: ref, platform: platform, progressUpdate: progress.handler) else {
76+
return try await ClientImage.fetch(reference: ref, platform: platform, progressUpdate: progress.handler)
5977
}
6078
return img
6179
}()

Sources/ContainerBuild/BuildPipelineHandler.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public actor BuildPipeline {
3030
[
3131
try BuildFSSync(URL(filePath: config.contextDir)),
3232
try BuildRemoteContentProxy(config.contentStore),
33-
try BuildImageResolver(config.contentStore),
33+
try BuildImageResolver(config.contentStore, quiet: config.quiet, output: config.terminal?.handle ?? FileHandle.standardError),
3434
try BuildStdio(quiet: config.quiet, output: config.terminal?.handle ?? FileHandle.standardError),
3535
]
3636
}

0 commit comments

Comments
 (0)