microsoft / microsoft/WSL

wslc build: support tar build contexts from stdin

Open
#41,629 3 comments 0 reactions 0 assignees View on GitHub
feature wslc
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

**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:

```console
tar -czf context.tar.gz -C context .
wslc build --tag stdin-context:test - < context.tar.gz
```

Currently, `-` 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:

```console
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 ` 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:

```console
docker build - < context.tar.gz
docker build --file test.Dockerfile - < context.tar.gz
```

**Describe 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 by `COPY`, `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

Contributor guide

Open the contributing guide

Research direction

Start at the wslc build command's positional context parsing and existing --file - stdin behavior. Trace how the Dockerfile and .dockerignore are resolved, then add coverage for tar input, invalid archives, interactive stdin, and both inputs set to -; done means streamed contexts build successfully with clear errors for unsupported cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system, cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.