File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed
Sources/ContainerCommands Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -207,7 +207,33 @@ extension Application {
207207 buildFilePath = resolvedPath
208208 }
209209
210- let buildFileData = try Data ( contentsOf: URL ( filePath: buildFilePath) )
210+ let buildFileData : Data
211+ let tempFile = FileManager . default. temporaryDirectory. appendingPathComponent ( " TempDockerfile " )
212+ defer {
213+ try ? FileManager . default. removeItem ( at: tempFile)
214+ }
215+
216+ // Dockerfile should be read from stdin
217+ if file == " - " {
218+ guard FileManager . default. createFile ( atPath: tempFile. path ( ) , contents: nil ) else {
219+ throw ContainerizationError ( . internalError, message: " unable to create temporary file " )
220+ }
221+
222+ guard let outputHandle = try ? FileHandle ( forWritingTo: tempFile) else {
223+ throw ContainerizationError ( . internalError, message: " unable to open temporary file for writing " )
224+ }
225+
226+ let bufferSize = 4096
227+ while true {
228+ let chunk = FileHandle . standardInput. readData ( ofLength: bufferSize)
229+ if chunk. isEmpty { break }
230+ outputHandle. write ( chunk)
231+ }
232+ try outputHandle. close ( )
233+ buildFileData = try Data ( contentsOf: URL ( filePath: tempFile. path ( ) ) )
234+ } else {
235+ buildFileData = try Data ( contentsOf: URL ( filePath: buildFilePath) )
236+ }
211237
212238 let systemHealth = try await ClientHealthCheck . ping ( timeout: . seconds( 10 ) )
213239 let exportPath = systemHealth. appRoot
You can’t perform that action at this time.
0 commit comments