buildkit icon indicating copy to clipboard operation
buildkit copied to clipboard

Support extracting `ADD --checksum=.. https://.. ..`

Open fenollp opened this issue 3 months ago • 6 comments

Today, ADD only extracts archives sources from the local context. fetched URLs aren't decompressed.

Since then, --checksum= was introduced and I believe this exact feature should now allow to extract (checksum'd) URLs!

I propose introducing a new BuildKit built-in build arg (e.g. ARG BUILDKIT_ADD_URLS_EXTRACTED=1) that makes it so that ADD extracts the downloaded & digested content.

  • Using --checksum=.. without this ARG, current behavior is preserved: failure.
  • ARG can be set stage-level as well as dockerfile-level but maybe shouldn't be set on daemon-level without bells on whistles.

Example (non-working today):

docker build --no-cache --output=type=tar,dest=./myar.tar - <<EOF
# syntax=docker.io/docker/dockerfile:sometag
FROM scratch
ARG BUILDKIT_ADD_URLS_EXTRACTED=1
ADD --chmod=0664 --checksum=sha256:e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae \
  https://static.crates.io/crates/proc-macro2/proc-macro2-1.0.78.crate /
EOF

And myar.tar then contains /Cargo.toml, /src/lib.rs, ...

Finally, I'd like to then also discuss the addition of a subflag: to enable tar's --strip-components=1.

fenollp avatar May 09 '24 14:05 fenollp