diff --git a/components/engine/integration/build/build_test.go b/components/engine/integration/build/build_test.go index 25c5e635bd..9dde5d4557 100644 --- a/components/engine/integration/build/build_test.go +++ b/components/engine/integration/build/build_test.go @@ -423,6 +423,38 @@ RUN [ ! -f foo ] assert.Check(t, is.Contains(out.String(), "Successfully built")) } +// #37581 +func TestBuildWithHugeFile(t *testing.T) { + ctx := context.TODO() + defer setupTest(t)() + + dockerfile := `FROM busybox +# create a sparse file with size over 8GB +RUN for g in $(seq 0 8); do dd if=/dev/urandom of=rnd bs=1K count=1 seek=$((1024*1024*g)) status=none; done && \ + ls -la rnd && du -sk rnd` + + buf := bytes.NewBuffer(nil) + w := tar.NewWriter(buf) + writeTarRecord(t, w, "Dockerfile", dockerfile) + err := w.Close() + assert.NilError(t, err) + + apiclient := testEnv.APIClient() + resp, err := apiclient.ImageBuild(ctx, + buf, + types.ImageBuildOptions{ + Remove: true, + ForceRemove: true, + }) + + out := bytes.NewBuffer(nil) + assert.NilError(t, err) + _, err = io.Copy(out, resp.Body) + resp.Body.Close() + assert.NilError(t, err) + assert.Check(t, is.Contains(out.String(), "Successfully built")) +} + func writeTarRecord(t *testing.T, w *tar.Writer, fn, contents string) { err := w.WriteHeader(&tar.Header{ Name: fn,