Skip to content

Use zstd compression for docker images #7682

@jchorl

Description

@jchorl

Is your feature request related to a problem? Please describe.

The megalinter images are big. They take a while to pull over the wire and extract. This hits cold CI workers particularly hard. It is great that there are variants but even those are large, and sometimes you want the whole gamut of linters.

Describe the solution you'd like

Docker/OCI have supported zstd for a while now. You can get better compression ratios with more efficient extraction.

I ran a quick test locally:

docker buildx build \       
    --platform linux/amd64 \
    --output type=oci,dest=image-zstd.tar.zstd,compression=zstd,compression-level=9,force-compression=true \
    .
docker buildx build \
    --platform linux/amd64 \
    --output type=oci,dest=image-gzip.tar.gz,compression=gzip,compression-level=9,force-compression=true \  
    .
du -sh image-*
4.5G    image-gzip.tar.gz
4.5G    image-raw.tar
3.8G    image-zstd.tar.zstd

I believe all that's required is to swap

with something like:

outputs: type=registry,compression=zstd,compression-level=9,force-compression=true

See docs on the github action: https://github.com/docker/build-push-action/tree/789f68658055d3ca993799b232b5c46dfe3f114d

Of note, I would expect this to slow down the build. It's a pay-once-every-pull-benefits type of change.

Describe alternatives you've considered

N/A

Additional context

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions