Skip to content

Commit 21c9a6a

Browse files
committed
doc: add sandbox with codapi-cli
1 parent ca246d8 commit 21c9a6a

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ To run Codapi locally, follow these steps:
3030

3131
```sh
3232
mkdir ~/codapi && cd ~/codapi
33-
curl -L -o codapi.tar.gz "https://github.com/nalgeon/codapi/releases/download/v0.10.0/codapi_0.10.0_linux_amd64.tar.gz"
33+
curl -L -o codapi.tar.gz "https://github.com/nalgeon/codapi/releases/download/v0.11.0/codapi_0.11.0_linux_amd64.tar.gz"
3434
tar xvzf codapi.tar.gz
35-
chmod +x codapi
3635
rm -f codapi.tar.gz
3736
```
3837

@@ -48,20 +47,22 @@ docker build --file sandboxes/ash/Dockerfile --tag codapi/ash:latest sandboxes/a
4847
./codapi
4948
```
5049

51-
Running in production is a bit more involved. See these guides:
52-
53-
- [Installing Codapi](docs/install.md)
54-
- [Updating Codapi](docs/update.md)
55-
- [Deploying to production](docs/production.md)
56-
5750
## Usage
5851

59-
See [Adding a sandbox](docs/add-sandbox.md) to create a custom sandbox.
52+
See [Adding a sandbox](docs/add-sandbox.md) to add a sandbox from the [registry](https://github.com/nalgeon/sandboxes) or create a custom one.
6053

6154
See [API](docs/api.md) to run sandboxed code using the HTTP API.
6255

6356
See [codapi-js](https://github.com/nalgeon/codapi-js) to embed the JavaScript widget into a web page.
6457

58+
## Production
59+
60+
Running in production is a bit more involved. See these guides:
61+
62+
- [Installing Codapi](docs/install.md)
63+
- [Updating Codapi](docs/update.md)
64+
- [Deploying to production](docs/production.md)
65+
6566
## Contributing
6667

6768
Contributions are welcome. For anything other than bugfixes, please first open an issue to discuss what you want to change.

docs/add-sandbox.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,27 @@ A _sandbox_ is an isolated execution environment for running code snippets. A sa
44

55
Codapi comes with a single `ash` sandbox preinstalled, but you can easily add others. Let's see some examples.
66

7-
## Python
7+
## Add a sandbox from the registry
8+
9+
The [sandboxes](https://github.com/nalgeon/sandboxes) repository contains several dozen ready-to-use sandboxes, from Go and Rust, to PostgreSQL and ClickHouse, to Caddy and Ripgrep.
10+
11+
To add a sandbox, use `codapi-cli` like this:
12+
13+
```text
14+
./codapi-cli sandbox add <name>
15+
```
16+
17+
For example:
18+
19+
```sh
20+
./codapi-cli sandbox add lua
21+
./codapi-cli sandbox add go
22+
./codapi-cli sandbox add mariadb
23+
```
24+
25+
Then restart the Codapi server and you're done.
26+
27+
## Create a sandbox from scratch
828

929
First, let's create a Docker image capable of running Python with some third-party packages:
1030

docs/install.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ docker run hello-world
2828

2929
```sh
3030
cd /opt/codapi
31-
curl -L -o codapi.tar.gz "https://github.com/nalgeon/codapi/releases/download/v0.10.0/codapi_0.10.0_linux_amd64.tar.gz"
31+
curl -L -o codapi.tar.gz "https://github.com/nalgeon/codapi/releases/download/v0.11.0/codapi_0.11.0_linux_amd64.tar.gz"
3232
tar xvzf codapi.tar.gz
33-
chmod +x codapi
3433
rm -f codapi.tar.gz
3534
```
3635

docs/update.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ cd /opt/codapi
1616
export version="0.x.x"
1717
curl -L -o codapi.tar.gz "https://github.com/nalgeon/codapi/releases/download/${version}/codapi_${version}_linux_amd64.tar.gz"
1818
tar xvzf codapi.tar.gz
19-
chmod +x codapi
2019
rm -f codapi.tar.gz
2120
```
2221

0 commit comments

Comments
 (0)