devbox/README.md
shoemoney c19ed20311
Some checks are pending
CI / vet-build-test (push) Waiting to run
docs: link public GitHub and Forgejo release downloads
2026-11-27 20:05:57 -06:00

309 lines
13 KiB
Markdown

<div align="center">
# 📦 devbox
### Your working tree, everywhere. Now with built-in Tailscale. 🔒
Continuous file sync for developers: private networking, selective mounts,
conflict copies, snapshot history, and a secret guard that keeps credentials home.
**Linux · macOS · Windows · Raspberry Pi**
[Install](#-install) · [Tailscale quick start](#-tailscale-quick-start) · [Commands](#-commands) · [Configuration](#-configuration) · [Build](#-build-and-release)
</div>
---
## 🔒 Built-in Tailscale, one hub binary
Run your own sync hub on a NAS, Pi, server, or spare computer. **The hub can join
its tailnet directly** using embedded [Tailscale (`tsnet`)](https://tailscale.com/docs/features/tsnet).
No separate Tailscale installation on the hub, root privileges, TUN device,
router port forwarding, or reverse proxy is required for this mode.
```bash
devbox-hub serve --data ./hub-data --tailscale --tailscale-hostname devbox-hub
```
On first launch, open the authentication URL printed in the terminal. Once
connected, the hub prints its private endpoint:
```text
http://devbox-hub.<your-tailnet>.ts.net:8080
```
**The `http://` endpoint travels inside Tailscale's encrypted network.** Embedded
mode exposes the hub API only through its Tailscale node; it does not also open
the API port on your machine's LAN or public interfaces. Tailnet access rules
still apply, and devbox's own join tokens and bearer authentication remain required.
**This release embeds Tailscale in the hub.** Client machines need the regular
Tailscale app, connected to a tailnet that can reach the hub. The `devbox` client
uses the private URL through that connection. Embedded client networking is not
included in this release. The embedded hub is a separate Tailscale device, even
if its host machine already runs Tailscale.
## ✨ Why devbox?
Git records the work you choose to commit. devbox continuously mirrors the
working files you are editing across your machines, including uncommitted work.
- **Live, bidirectional sync.** A filesystem watcher sends changes; peers receive
them through a persistent event stream. Periodic rescans catch missed events.
- **Developer-friendly filtering.** `.devignore` uses gitignore syntax. Optional
default ignores skip caches, dependencies, and build output.
- **Secret guard.** Default deny patterns block `.env` files, private keys, and
credential paths independently of `.devignore`; add your own patterns too.
- **Conflict copies.** Concurrent edits preserve losing file versions as
`.conflict-*` copies instead of silently discarding them.
- **Efficient transfers.** FastCDC chunking, BLAKE3 content addressing, deduplication,
optional gzip, and bandwidth caps reduce repeated uploads.
- **Selective mounts.** Mount a whole share or one subdirectory, read-write or
read-only. Per-device exclusions keep local choices local.
- **Snapshots and deployment.** Browse history, restore a file or tree, or pin a
mount to a snapshot for a deployment.
- **Hooks and visibility.** Run lifecycle hooks, inspect JSON status, diagnose
problems with `doctor`, and enable the hub's built-in live dashboard.
## ⚡ Install
**Linux / macOS client:**
```bash
curl -fsSL https://git.shoemoney.ai/shoemoney/devbox-dist/releases/download/latest/install.sh | sh
```
**Install the hub as well:**
```bash
curl -fsSL https://git.shoemoney.ai/shoemoney/devbox-dist/releases/download/latest/install.sh -o install.sh
sh install.sh --hub --no-service
```
`--service` installs a keep-alive service for the **client sync daemon**. Run the
hub separately, or configure its own service with the `serve` arguments below.
**Windows (PowerShell):**
```powershell
irm https://git.shoemoney.ai/shoemoney/devbox-dist/releases/download/latest/install.ps1 | iex
```
Download from [GitHub Releases](https://github.com/shoemoney/devbox/releases) or
the [Forgejo distribution mirror](https://git.shoemoney.ai/shoemoney/devbox-dist/releases).
Both are public. Release downloads include `devbox` and `devbox-hub` for Linux amd64/arm64/arm,
macOS amd64/arm64, and Windows amd64, plus `SHA256SUMS`. The shell installer
supports amd64 and arm64; download the Linux arm binaries directly for 32-bit Pi OS.
Use `--release-url` / `DEVBOX_RELEASE_URL` to select a versioned release.
## 🚀 Tailscale quick start
### 1. Start your private hub
```bash
devbox-hub serve --data ./hub-data --tailscale --tailscale-hostname devbox-hub
```
Authenticate using the terminal's login URL. The default startup deadline is two
minutes; allow longer with `--tailscale-start-timeout 5m` if needed. Keep the hub
running and use another terminal for administrative commands.
For unattended first enrollment, set **`TS_AUTHKEY`** in the service environment
or a protected environment file. Do not commit it or put it in command-line
arguments. Once enrolled, the persisted state reconnects without the auth key.
The embedded node stores its identity under **`<data>/tailscale`**, with a private
state directory. Keep this directory across upgrades and include it in protected
filesystem backups. Do not share one state directory between running hub processes
or clone the same node identity onto multiple hosts. `devbox-hub backup` backs up
the hub database and blobs; separately preserve the Tailscale state directory.
### 2. Enroll the first client
On the hub machine, mint a one-time token:
```bash
devbox-hub token --data ./hub-data
```
On your client, connect the Tailscale app, then use the endpoint printed by the hub:
```bash
devbox join http://devbox-hub.<your-tailnet>.ts.net:8080 <join-token>
devbox publish ~/Projects projects
devbox start
```
The hostname is an example: Tailscale may assign a different name when a device
with that name already exists. Use the actual printed endpoint. MagicDNS must be
available on clients to use its hostname; the hub's Tailscale IP works too.
### 3. Mount it on another machine
Mint a **new** token on the hub, connect that machine's Tailscale app, then:
```bash
devbox join http://devbox-hub.<your-tailnet>.ts.net:8080 <another-join-token>
devbox mount projects ~/Projects
devbox start
```
For a subdirectory or read-only checkout:
```bash
devbox mount projects/my-app ~/work/my-app
devbox mount projects ~/mirror --ro
```
Run `devbox doctor` if the connection fails. Check that the hub is running, the
client is connected to Tailscale, and tailnet policy allows its connection to
port 8080. A Tailscale login does not replace a devbox join token.
### Tailscale options
| Hub flag | Default | Purpose |
|---|---|---|
| `--tailscale` | off | Enable the embedded, tailnet-only API listener |
| `--tailscale-hostname` | `devbox-hub` | Requested name for this Tailscale node |
| `--tailscale-state-dir` | `<data>/tailscale` | Persistent Tailscale identity directory |
| `--tailscale-start-timeout` | `2m` | Maximum time to connect and authenticate |
| `--listen` | `:8080` | API port; in embedded mode use `:PORT` |
Tailscale mode accepts a wildcard listen address and serves that port on its own
node only. An explicit host such as `127.0.0.1:8080` is rejected instead of being
silently overridden. The optional dashboard remains a separate host listener
(default `127.0.0.1:8099`); `--tailscale` does not publish it to the tailnet.
## 🌐 Regular networking
Tailscale is opt-in. Existing LAN and reverse-proxy deployments keep working:
```bash
devbox-hub serve --data ./hub-data --listen 127.0.0.1:8088
# Configure your TLS proxy to reach 127.0.0.1:8088, then:
devbox join https://hub.example.com <join-token>
```
The ordinary listener speaks plain HTTP. Use a TLS reverse proxy when traffic
crosses an untrusted network. Allow large uploads, disable proxy buffering, and
allow long-lived responses for `/v1/events` (SSE).
The repository's `docker-compose.yml` runs the ordinary LAN listener. For an
embedded Tailscale container, use the built image with a persistent `/data`
volume and command `serve --data /data --tailscale --listen :8088`; no published
API port or `/dev/net/tun` is needed. Supply `TS_AUTHKEY` securely on first run
or authenticate through the container logs. The ordinary Compose healthcheck
probes the host-network API, so it must be replaced for tailnet-only mode.
## 🧰 Commands
| Client command | Purpose |
|---|---|
| `devbox setup` | Interactive first-run setup |
| `devbox join <hub> <token>` | Enroll this device |
| `devbox publish <localdir> <share>` | Create a share and push its files |
| `devbox mount <share[/subpath]> <localdir>` | Mount and pull a share |
| `devbox unmount <share>` | Remove a local mount |
| `devbox start` / `stop` | Run or stop the sync daemon |
| `devbox pause` / `resume` | Pause or resume daemon sync |
| `devbox status --json` | Inspect device and mount status |
| `devbox doctor --json` | Diagnose config, connection, and filesystem issues |
| `devbox log <share>` | List snapshots |
| `devbox restore <share> <snapshot> [path]` | Restore a file or share |
| `devbox deploy <share> <snapshot>` | Pin a mount to a snapshot |
| `devbox conflicts` | List conflict copies |
| `devbox ignore <pattern>` | Add an ignore pattern |
| `devbox hook list <share>` | Inspect lifecycle hooks |
| `devbox invite <share> <principal> <role>` | Invite a member with a per-share role |
| `devbox members <share>` | List memberships |
Hub administration includes `token`, `readonly`, `revoke`, `member`, `principal`,
`share ls`, `device ls`, `backup`, `fsck`, and `gc`. Run `<command> --help` for
arguments. Memberships support viewer, editor, admin, and owner roles; this
release's membership layer enforces writes. Read-side ACL enforcement remains
planned, so use a hub for a trusted group rather than mutually untrusted tenants.
## 📊 Built-in dashboard
<p align="center"><img src="docs/images/dashboard.png" alt="devbox live sync dashboard" width="860"></p>
```bash
devbox-hub serve --data ./hub-data --tailscale --dashboard
# Dashboard: http://127.0.0.1:8099 on the hub host
```
The dashboard shows devices, shares, transfers, and conflicts. It is optional,
separate from the API, and local by default. Use `--dashboard-token` when exposing
it beyond loopback. `/healthz`, `/readyz`, and Prometheus `/metrics` are available
on the API listener; `--metrics-token` can restrict metrics access.
## ⚙️ Configuration
Machine configuration lives at `$XDG_CONFIG_HOME/devbox`, otherwise
`~/.config/devbox` on Linux/macOS or `%AppData%\devbox` on Windows.
`daemon.toml` holds enrollment and mounts; `config.toml` holds tunables:
```toml
[transfer]
max_kbps = 0
compress = true
[sync]
rescan_seconds = 60
ignore_defaults = true
[secrets]
extra_patterns = ["*.secret", "vault-*"]
```
`.devignore` filters a share. Device-local mount exclusions avoid syncing a path
on one machine without changing peers. Secret filtering is independent of both.
Hooks support pre/post push and pull plus conflict events; a pre-hook can veto
an operation. The hook runner requires bash (or PowerShell for `.ps1` hooks).
On macOS, grant the `devbox` binary Full Disk Access when syncing protected
folders such as Desktop, Documents, Downloads, or iCloud. `devbox doctor` checks
mount access and reports failures.
## 🛡️ Data and upgrades
Devices have Ed25519 identities and prove possession during enrollment. The hub
stores bearer-token hashes; downloaded chunks and manifests are checked against
their content hashes. Incoming paths are checked for mount containment, and
atomic file replacement uses fsync for durability.
Keep backups of the hub's data and identity. `deploy/redeploy-hub.sh` provides a
gated upgrade flow: migration check on a copy, isolated auth smoke, backup,
binary replacement, live verification, and rollback on failure. Review its host
settings before running it. For embedded mode, preserve the Tailscale directory
and the hub service's `--tailscale` arguments during upgrades.
## 🏗️ Build and release
Building the current embedded hub requires **Go 1.27.4 or newer**, matching the
pinned Tailscale dependency. Downloading prebuilt binaries needs no Go toolchain.
```bash
go build ./cmd/devbox ./cmd/devbox-hub
go vet ./...
go test -race ./...
VERSION=v2.1.0 ./scripts/build-release.sh
```
The release script cross-compiles both binaries for six platform/architecture
combinations and generates checksums. Public binaries are available through
[GitHub Releases](https://github.com/shoemoney/devbox/releases) and the Forgejo
[`devbox-dist`](https://git.shoemoney.ai/shoemoney/devbox-dist) mirror. The default
installer uses Forgejo; `--release-url` can select either host.
Design documents: [original sync design](docs/superpowers/specs/2026-06-22-devbox-design.md)
and [v2 roadmap](docs/V2-SPEC.md). Future work includes embedded client networking,
read-side ACLs, client-side encryption, and peer chunk exchange. Tailscale
transport encryption protects the connection; it does not encrypt stored hub
files or replace end-to-end file encryption.
## ⚖️ License
The hub and client are licensed under [AGPLv3](LICENSE). Self-host the core for
free. See dependency licenses for third-party components, including Tailscale.