wslc build: support tar build contexts from stdin
Is your feature request related to a problem? Please describe.
wslc build currently requires its positional build context to be a directory. It does not support using - to read a tar build context from standard input:
tar -czf context.tar.gz -C context .
wslc build --tag stdin-context:test - < context.tar.gzCurrently, - is interpreted as a host filesystem path and rejected because it is not a directory.
This prevents tools and pipelines from generating or filtering a build context as a tar stream and passing it directly to WSLC. Callers must instead materialize the context as a temporary directory, adding disk I/O, cleanup, and failure-handling requirements.
This is distinct from --file -, which reads only the Dockerfile from stdin while the build context still comes from a directory.
Describe the solution you'd like
Allow - as the positional build context:
wslc build [OPTIONS] -When stdin contains a tar archive, use the archive contents as the filesystem build context. The default Dockerfile and .dockerignore should be resolved from the archive root, and --file <path> should resolve the specified Dockerfile relative to that root.
At minimum, uncompressed tar archives should be supported. Ideally, this would match Docker's support for identity, gzip, bzip2, and xz-compressed tar streams.
Invalid archives or an interactive stdin should produce an actionable error. If both the context and --file are -, the command should also report clearly that both inputs cannot consume the same stream.
This would provide behavior equivalent to:
docker build - < context.tar.gz
docker build --file test.Dockerfile - < context.tar.gzDescribe alternatives you've considered
- Unpack the tar stream into a temporary directory and pass that directory to
wslc build. This works, but defeats streaming and requires additional disk space, cleanup, and error handling. - Use
--file -. This only supplies the Dockerfile through stdin and does not provide the files needed byCOPY,ADD, or other context-dependent operations.
Additional context
Docker documents tar build contexts supplied over stdin here:
https://docs.docker.com/build/concepts/context/#local-tarballs
Source: microsoft/WSL