Repository navigation
Description
What are you trying to do?
Add a first-class Dagger API for extracting archive File objects into Directory values.
Today, when a Dagger pipeline downloads or produces an archive, users commonly need to create a throwaway container, mount the archive, install/use an extraction tool, and run something like bsdtar to unpack it before continuing with normal Directory operations.
A core API would let users write this as a normal Dagger data-flow operation instead of shelling out through a container.
Possible API shape, naming TBD:
archive := dag.HTTP("https://example.com/source.tar.gz")
src := archive.Extract()or:
src := archive.AsDirectory(dagger.FileAsDirectoryOpts{
Format: "tar.gz", // optional; auto-detect when omitted
StripComponents: 1,
})The key behavior requested here is File -> Directory archive extraction. It should probably support the common formats users already reach for bsdtar to handle, such as .tar, .tar.gz, .tgz, .tar.xz, and .zip, subject to whatever set is appropriate for the engine API.
Why is this important?
Archive extraction is a common CI/CD pipeline step. Without a core API, users repeat boilerplate like:
- Start an Alpine/debian/etc. container.
- Install or rely on
tar/bsdtar/unzip. - Mount the archive file and an output directory.
- Run an extraction command.
- Continue with the extracted
Directory.
That workaround is noisy, image-dependent, and less portable than a Dagger-native filesystem operation. It also makes module APIs less clear because a data transformation that conceptually returns a Directory is expressed as container execution plumbing.
Prior context
- Earlier issue: ✨ core function to get a directory or file as tarball #9125
- That issue requested
Directory.AsTarball()/File.AsTarball()and also mentioned the reverse operation: “to get a directory from a tarball.” - Maintainer context: ✨ core function to get a directory or file as tarball #9125 (comment) says Dagger should also support unpacking files/directories.
- Related user comment: ✨ core function to get a directory or file as tarball #9125 (comment) mentions this would help work around
.Exportpartially transfers files and then gets stuck #6355.
- That issue requested
- Discord context that prompted this issue:
- Original archive extraction question /
bsdtarworkaround: https://discord.com/channels/707636530424053791/1512826870859563058/1512826870859563058 - Follow-up lookup result noting ✨ core function to get a directory or file as tarball #9125 was the closest match and no open replacement was found: https://discord.com/channels/707636530424053791/1512826870859563058/1512883365525848179
- Request to file this new issue: https://discord.com/channels/707636530424053791/1512826870859563058/1513283854499184942
- Original archive extraction question /
Current workaround
Use a container with an extraction tool, for example bsdtar, mount the archive File, extract to a mounted directory, then return/read that directory.
Open questions
- Should this live on
File, for exampleFile.Extract()orFile.AsDirectory()? - Should format be auto-detected from content, filename, or explicitly passed?
- Which formats should be guaranteed by core?
- Should options include
stripComponents, include/exclude filters, overwrite behavior, and path traversal protections?
Activity
sagikazarmark commentedon Jun 7, 2026
Extractas the API. AsDirectory is ambigous and non-obviousdagger-codex commentedon Jun 7, 2026
Sanity check before implementation:
The updated direction looks implementable as a
File.extract(...) -> DirectoryAPI. My read of the intended v1 contract is:File.extract, notasDirectory.Directory.stripComponents.DirectoryAPIs afterward..tar,.tgz/.tar.gz,.tar.xz, and.zip.Questions to settle before coding:
formatoption at all, or should it be auto-detect only until there is a concrete need for override?stripComponentsapply uniformly to both tar and zip entry paths, with entries that do not have enough path components skipped liketar --strip-components?..after normalization..tar.xzrequired in the first PR? It is in the suggested format list, but it likely means adding/using an xz decoder dependency, unlike plain tar/gzip/zip.If those defaults are right, I can proceed with an implementation around that contract.
core: add File.extract to extract archives into directories
core: add File.extract to extract archives into directories
core: add File.extract to extract archives into directories
core: add File.extract to extract archives into directories