> ## Documentation Index
> Fetch the complete documentation index at: https://docs.envlink.projectinwork.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Build remotely

> Run builds and tests in a leased linux-build box and get the results back as local files.

`linux-build` is a Linux box with Go, C and C++ (gcc, cmake), Python, Node and Bazel. You share your folder to its `/work`, run commands there with `envctl exec`, and whatever lands in `/work/out` comes back.

## Lease a box

From the folder you ran `envctl sandbox up` in:

```bash theme={null}
envctl env create linux-build --share src=. --label task=fix-login
```

`--share src=.` maps the template's `src` share to this folder. Use a subfolder, like `--share src=./services/api`, to send only part of a repository.

## Run the build

```bash theme={null}
envctl exec linux-build-3f2a -- sh -c 'cd /work && make test'
```

* Before the command runs, `exec` syncs your latest edits and waits for the box to acknowledge them.
* Output streams back as it happens, and `envctl` exits with the remote exit code.
* The box doesn't go idle while a command runs, and every command is recorded in the environment's log in the console.

## Get the results

Write outputs under `/work/out`:

```bash theme={null}
envctl exec linux-build-3f2a -- sh -c 'cd /work && go build -o out/server ./cmd/server'
ls -l .remote/linux-build-3f2a/out/server
```

They're on your machine by the time `exec` returns, under `.remote/<environment>/out/`. `.remote/` is never synced back up.

## Caches

The box keeps tool caches on its own `/cache` volume for as long as it lives: `GOCACHE`, `GOMODCACHE`, npm's and pip's caches, and Bazel's state. A second build in the same box is incremental. To carry your source between boxes, use [snapshots](/guides/snapshots). For Bazel actions shared across boxes, use the [Bazel cache](/guides/bazel).

## Find and reuse a box

```bash theme={null}
envctl env list --label task=fix-login
envctl exec "$(envctl env list --label task=fix-login --json | jq -r '.[0].name')" -- make
```

## Clean up

```bash theme={null}
envctl env delete linux-build-3f2a
```

<Tip>
  Shorten how long a forgotten box lives with `--idle 20m`, or cap it with `--hard 2h`.
</Tip>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.