diff --git a/pkg/overlay/pack.go b/pkg/overlay/pack.go index dad09720..641b6ec9 100644 --- a/pkg/overlay/pack.go +++ b/pkg/overlay/pack.go @@ -10,6 +10,7 @@ import ( "path/filepath" "runtime" "strings" + "sync" "time" "github.com/klauspost/pgzip" @@ -29,6 +30,14 @@ import ( "stackerbuild.io/stacker/pkg/types" ) +var tarEx sync.Mutex + +// Container image layers are often tar.gz, however there is nothing in the +// spec or documentation which standardizes compression params which can cause +// different layer hashes even for the same tar. So picking compression params +// that most tooling appears to be using. +const gzipBlockSize = mutate.GzipBlockSize(256 << 12) + func safeOverlayName(d digest.Digest) string { // dirs used in overlay lowerdir args can't have : in them, so lets // sanitize it @@ -418,7 +427,7 @@ func generateLayer(config types.StackerConfig, oci casext.Engine, mutators []*mu defer blob.Close() if layerType.Type == "tar" { - desc, err = mutator.Add(context.Background(), mediaType, blob, history, mutate.GzipCompressor, nil) + desc, err = mutator.Add(context.Background(), mediaType, blob, history, mutate.GzipCompressor.WithOpt(gzipBlockSize), nil) if err != nil { return false, err }