Skip to content

Commit 65f0341

Browse files
committed
update examples
1 parent 39cd0c3 commit 65f0341

2 files changed

Lines changed: 43 additions & 77 deletions

File tree

EXAMPLES.md

Lines changed: 36 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,21 @@ Runnable examples live in [`examples/`](./examples).
77

88
## Table of Contents
99

10-
- [Examples](#examples)
11-
- [Table of Contents](#table-of-contents)
12-
- [Blueprint with Build Context](#blueprint-with-build-context)
13-
- [Workflow](#workflow)
14-
- [Prerequisites](#prerequisites)
15-
- [Run](#run)
16-
- [Test](#test)
17-
- [Devbox From Blueprint (Run Command, Shutdown)](#devbox-from-blueprint-run-command-shutdown)
18-
- [Workflow](#workflow-1)
19-
- [Prerequisites](#prerequisites-1)
20-
- [Run](#run-1)
21-
- [Test](#test-1)
22-
- [Devbox Tunnel (HTTP Server Access)](#devbox-tunnel-http-server-access)
23-
- [Workflow](#workflow-2)
24-
- [Devbox Snapshot and Resume](#devbox-snapshot-and-resume)
25-
- [Workflow](#workflow-3)
26-
- [Prerequisites](#prerequisites-2)
27-
- [Run](#run-2)
28-
- [Test](#test-2)
29-
- [MCP Hub + Claude Code + GitHub](#mcp-hub--claude-code--github)
30-
- [Workflow](#workflow-4)
31-
- [Prerequisites](#prerequisites-3)
32-
- [Run](#run-3)
33-
- [Test](#test-3)
34-
- [Secrets with Devbox (Create, Inject, Verify, Delete)](#secrets-with-devbox-create-inject-verify-delete)
35-
- [Workflow](#workflow-5)
36-
- [Prerequisites](#prerequisites-4)
37-
- [Run](#run-4)
38-
- [Test](#test-4)
10+
- [Blueprint with Build Context](#blueprint-with-build-context)
11+
- [Devbox From Blueprint (Run Command, Shutdown)](#devbox-from-blueprint-lifecycle)
12+
- [Devbox Snapshot and Resume](#devbox-snapshot-resume)
13+
- [Devbox Tunnel (HTTP Server Access)](#devbox-tunnel)
14+
- [MCP Hub + Claude Code + GitHub](#mcp-github-tools)
15+
- [Secrets with Devbox (Create, Inject, Verify, Delete)](#secrets-with-devbox)
3916

4017
<a id="blueprint-with-build-context"></a>
41-
4218
## Blueprint with Build Context
4319

4420
**Use case:** Create a blueprint using the object store to provide docker build context files, then verify files are copied into the image. Uses the async SDK.
4521

4622
**Tags:** `blueprint`, `object-store`, `build-context`, `devbox`, `cleanup`, `async`
4723

4824
### Workflow
49-
5025
- Create a temporary directory with sample application files
5126
- Upload the directory to object storage as build context
5227
- Create a blueprint with a Dockerfile that copies the context files
@@ -55,33 +30,28 @@ Runnable examples live in [`examples/`](./examples).
5530
- Shutdown devbox and delete blueprint and storage object
5631

5732
### Prerequisites
58-
5933
- `RUNLOOP_API_KEY`
6034

6135
### Run
62-
6336
```sh
6437
uv run python -m examples.blueprint_with_build_context
6538
```
6639

6740
### Test
68-
6941
```sh
7042
uv run pytest -m smoketest tests/smoketests/examples/
7143
```
7244

7345
**Source:** [`examples/blueprint_with_build_context.py`](./examples/blueprint_with_build_context.py)
7446

7547
<a id="devbox-from-blueprint-lifecycle"></a>
76-
7748
## Devbox From Blueprint (Run Command, Shutdown)
7849

7950
**Use case:** Create a devbox from a blueprint, run a command, fetch logs, validate output, and cleanly tear everything down.
8051

8152
**Tags:** `devbox`, `blueprint`, `commands`, `logs`, `cleanup`
8253

8354
### Workflow
84-
8555
- Create a blueprint
8656
- Fetch blueprint build logs
8757
- Create a devbox from the blueprint
@@ -91,49 +61,28 @@ uv run pytest -m smoketest tests/smoketests/examples/
9161
- Shutdown devbox and delete blueprint
9262

9363
### Prerequisites
94-
9564
- `RUNLOOP_API_KEY`
9665

9766
### Run
98-
9967
```sh
10068
uv run python -m examples.devbox_from_blueprint_lifecycle
10169
```
10270

10371
### Test
104-
10572
```sh
10673
uv run pytest -m smoketest tests/smoketests/examples/
10774
```
10875

10976
**Source:** [`examples/devbox_from_blueprint_lifecycle.py`](./examples/devbox_from_blueprint_lifecycle.py)
11077

111-
<a id="devbox-tunnel"></a>
112-
113-
## Devbox Tunnel (HTTP Server Access)
114-
115-
**Use case:** Create a devbox, start an HTTP server, enable a tunnel, and access the server from the local machine through the tunnel. Uses the async SDK.
116-
117-
**Tags:** `devbox`, `tunnel`, `networking`, `http`, `async`
118-
119-
### Workflow
120-
121-
- Create a devbox
122-
- Start an HTTP server inside the devbox
123-
- Enable a tunnel for external access
124-
- Make an HTTP request from the local machine through the tunnel
125-
- Validate the response
126-
- Shutdown the devbox
127-
<a id="devbox-snapshot-resume"></a>
128-
78+
<a id="devbox-snapshot-resume"></a>
12979
## Devbox Snapshot and Resume
13080

13181
**Use case:** Create a devbox, snapshot its disk, resume from the snapshot, and demonstrate that changes in the original devbox do not affect the clone. Uses the async SDK.
13282

13383
**Tags:** `devbox`, `snapshot`, `resume`, `cleanup`, `async`
13484

13585
### Workflow
136-
13786
- Create a devbox
13887
- Write a file to the devbox
13988
- Create a disk snapshot
@@ -143,35 +92,58 @@ uv run pytest -m smoketest tests/smoketests/examples/
14392
- Shutdown both devboxes and delete the snapshot
14493

14594
### Prerequisites
146-
14795
- `RUNLOOP_API_KEY`
14896

14997
### Run
150-
15198
```sh
152-
uv run python -m examples.devbox_tunnel
15399
uv run python -m examples.devbox_snapshot_resume
154100
```
155101

156102
### Test
103+
```sh
104+
uv run pytest -m smoketest tests/smoketests/examples/
105+
```
106+
107+
**Source:** [`examples/devbox_snapshot_resume.py`](./examples/devbox_snapshot_resume.py)
157108

109+
<a id="devbox-tunnel"></a>
110+
## Devbox Tunnel (HTTP Server Access)
111+
112+
**Use case:** Create a devbox, start an HTTP server, enable a tunnel, and access the server from the local machine through the tunnel. Uses the async SDK.
113+
114+
**Tags:** `devbox`, `tunnel`, `networking`, `http`, `async`
115+
116+
### Workflow
117+
- Create a devbox
118+
- Start an HTTP server inside the devbox
119+
- Enable a tunnel for external access
120+
- Make an HTTP request from the local machine through the tunnel
121+
- Validate the response
122+
- Shutdown the devbox
123+
124+
### Prerequisites
125+
- `RUNLOOP_API_KEY`
126+
127+
### Run
128+
```sh
129+
uv run python -m examples.devbox_tunnel
130+
```
131+
132+
### Test
158133
```sh
159134
uv run pytest -m smoketest tests/smoketests/examples/
160135
```
161136

162137
**Source:** [`examples/devbox_tunnel.py`](./examples/devbox_tunnel.py)
163-
**Source:** [`examples/devbox_snapshot_resume.py`](./examples/devbox_snapshot_resume.py)
164138

165139
<a id="mcp-github-tools"></a>
166-
167140
## MCP Hub + Claude Code + GitHub
168141

169142
**Use case:** Connect Claude Code running in a devbox to GitHub tools through MCP Hub without exposing raw GitHub credentials to the devbox.
170143

171144
**Tags:** `mcp`, `devbox`, `github`, `commands`, `cleanup`
172145

173146
### Workflow
174-
175147
- Create an MCP config for GitHub
176148
- Store GitHub token as a Runloop secret
177149
- Launch a devbox with MCP Hub wiring
@@ -180,35 +152,30 @@ uv run pytest -m smoketest tests/smoketests/examples/
180152
- Shutdown devbox and clean up cloud resources
181153

182154
### Prerequisites
183-
184155
- `RUNLOOP_API_KEY`
185156
- `GITHUB_TOKEN (GitHub PAT with repo scope)`
186157
- `ANTHROPIC_API_KEY`
187158

188159
### Run
189-
190160
```sh
191161
GITHUB_TOKEN=ghp_xxx ANTHROPIC_API_KEY=sk-ant-xxx uv run python -m examples.mcp_github_tools
192162
```
193163

194164
### Test
195-
196165
```sh
197166
uv run pytest -m smoketest tests/smoketests/examples/
198167
```
199168

200169
**Source:** [`examples/mcp_github_tools.py`](./examples/mcp_github_tools.py)
201170

202171
<a id="secrets-with-devbox"></a>
203-
204172
## Secrets with Devbox (Create, Inject, Verify, Delete)
205173

206174
**Use case:** Create a secret, inject it into a devbox as an environment variable, verify access, and clean up.
207175

208176
**Tags:** `secrets`, `devbox`, `environment-variables`, `cleanup`
209177

210178
### Workflow
211-
212179
- Create a secret with a test value
213180
- Create a devbox with the secret mapped to an env var
214181
- Execute a command that reads the secret from the environment
@@ -218,17 +185,14 @@ uv run pytest -m smoketest tests/smoketests/examples/
218185
- Shutdown devbox and delete secret
219186

220187
### Prerequisites
221-
222188
- `RUNLOOP_API_KEY`
223189

224190
### Run
225-
226191
```sh
227192
uv run python -m examples.secrets_with_devbox
228193
```
229194

230195
### Test
231-
232196
```sh
233197
uv run pytest -m smoketest tests/smoketests/examples/
234198
```

examples/registry.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,19 @@
3333
"run": run_devbox_from_blueprint_lifecycle_example,
3434
},
3535
{
36-
"slug": "devbox-tunnel",
37-
"title": "Devbox Tunnel (HTTP Server Access)",
38-
"file_name": "devbox_tunnel.py",
39-
"required_env": ["RUNLOOP_API_KEY"],
40-
"run": run_devbox_tunnel_example,
4136
"slug": "devbox-snapshot-resume",
4237
"title": "Devbox Snapshot and Resume",
4338
"file_name": "devbox_snapshot_resume.py",
4439
"required_env": ["RUNLOOP_API_KEY"],
4540
"run": run_devbox_snapshot_resume_example,
4641
},
42+
{
43+
"slug": "devbox-tunnel",
44+
"title": "Devbox Tunnel (HTTP Server Access)",
45+
"file_name": "devbox_tunnel.py",
46+
"required_env": ["RUNLOOP_API_KEY"],
47+
"run": run_devbox_tunnel_example,
48+
},
4749
{
4850
"slug": "mcp-github-tools",
4951
"title": "MCP Hub + Claude Code + GitHub",

0 commit comments

Comments
 (0)