Skip to content

Commit 04e654e

Browse files
committed
fix: Restore tar archive write performance regressed by padding trim
1 parent d6cf08d commit 04e654e

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/Testcontainers/Images/DockerfileArchive.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public async Task<string> Tar(CancellationToken ct = default)
192192

193193
using (var tarOutputFileStream = new FileStream(dockerfileArchiveFilePath, FileMode.Create, FileAccess.Write))
194194
{
195-
using (var tarOutputStream = new TarOutputStream(tarOutputFileStream, TarArchiveDefaults.TarBlockFactor, Encoding.Default))
195+
using (var tarOutputStream = new TarOutputStream(tarOutputFileStream, Encoding.Default))
196196
{
197197
tarOutputStream.IsStreamOwner = false;
198198

src/Testcontainers/TarArchiveDefaults.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ internal static class TarArchiveDefaults
99
// blocks while the HTTP sender is still flushing the padding, causing EPIPE
1010
// (HTTP 500 "broken pipe"). See:
1111
// https://github.com/testcontainers/testcontainers-dotnet/issues/1683.
12+
//
13+
// This only applies to archives we stream to the daemon over a pipe (resource
14+
// mappings via a MemoryStream), where the surplus padding is both unnecessary
15+
// and harmful. Do NOT reuse it for the Dockerfile build context, which is
16+
// written to a FileStream on disk: a 512 B record forces a write and flush per
17+
// block and regresses image builds. That path keeps SharpZipLib's default block
18+
// factor on purpose.
1219
internal const int TarBlockFactor = 1;
1320
}
1421
}

0 commit comments

Comments
 (0)