fix: Compress build context before sending it to Docker (#461)

This fixes #439 by gzipping the build context, which prevents the Docker
API from misinterpreting the stream as a plain text Dockerfile.

Co-authored-by: Martin <Junkern@users.noreply.github.com>
This commit is contained in:
Benjamin Staffin 2025-04-11 07:03:00 -04:00 committed by GitHub
parent 7e1842ccd6
commit ae80eb7d7b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -410,6 +410,15 @@ func prepareBuildContext(specifiedContext string, specifiedDockerfile string) (i
if err != nil {
return nil, "", err
}
}
// Compress build context to avoid Docker misinterpreting it as plain text
if buildCtx != nil {
buildCtx, err = build.Compress(buildCtx)
if err != nil {
return nil, "", err
}
}
if relDockerfile != "" {
return buildCtx, relDockerfile, nil
}
return buildCtx, specifiedDockerfile, nil