Skip to content

Commit 94d6d0a

Browse files
Add an error message for dockerfile >= 16KB until apple#735 is resolved (apple#1634)
Closes apple#1633. We have a known issue apple#735 where Dockerfiles over the size 16kb will fail to build due to "Transport became inactive" or "Stream unexpectedly closed" errors. While we wait for a fix for apple#735, this PR adds an error message if a user tries to build an image using a dockerfile >= 16kb. Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
1 parent 7966302 commit 94d6d0a

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Sources/ContainerCommands/BuildCommand.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,20 @@ extension Application {
251251
ignoreFileData = try? Data(contentsOf: ignoreFileURL)
252252
}
253253

254+
// BUG: See https://github.com/apple/container/issues/735.
255+
// Reject dockerfiles larger than 16kb before attempting to build.
256+
// TODO: Remove when #735 was been resolved.
257+
let maxDockerfileSize = 16 * 1024 // 16 KiB
258+
guard buildFileData.count < maxDockerfileSize else {
259+
throw ContainerizationError(
260+
.invalidArgument,
261+
message: """
262+
Dockerfile size (\(buildFileData.count) bytes) exceeds the maximum allowed size of \(maxDockerfileSize) bytes. \
263+
See https://github.com/apple/container/issues/735.
264+
"""
265+
)
266+
}
267+
254268
let secretsData: [String: Data] = try self.secrets.mapValues { secret in
255269
switch secret {
256270
case .data(let data):

0 commit comments

Comments
 (0)