Installing Codapi
April 17, 2026 · View on GitHub
Make sure you install Codapi on a separate machine — this is a must for security reasons. Do not store any sensitive data or credentials on this machine. This way, even if someone runs malicious code that somehow escapes the isolated environment, they won't have access to your other machines and data.
Steps for Debian (11+):
- Install necessary packages:
sudo apt update && sudo apt install -y ca-certificates curl make unzip
Install Docker. Note: Do not install the docker.io package. Follow the official Docker instructions for Debian instead.
After installing Docker, start it:
sudo systemctl enable docker.service
sudo systemctl restart docker.service
Verify that Docker is working:
docker run hello-world
- Create Codapi user:
sudo useradd --groups docker --shell /usr/bin/bash --create-home --home /opt/codapi codapi
Install Codapi:
sudo su - codapi
cd /opt/codapi
curl -L -o codapi.tar.gz "https://github.com/nalgeon/codapi/releases/latest/download/codapi_0.13.1_linux_amd64.tar.gz"
tar xvzf codapi.tar.gz
rm -f codapi.tar.gz
- Build the sample
ashsandbox image:
sudo su - codapi
cd /opt/codapi
docker build --file sandboxes/ash/Dockerfile --tag codapi/ash:latest sandboxes/ash
Verify that Codapi starts without errors (as codapi):
sudo su - codapi
cd /opt/codapi
./codapi
It should list ash in both boxes and commands:
2023/09/16 15:18:05 codapi 20230915:691d224
2023/09/16 15:18:05 listening on port 1313...
2023/09/16 15:18:05 workers: 8
2023/09/16 15:18:05 boxes: [alpine]
2023/09/16 15:18:05 commands: [sh]
Stop it with Ctrl+C.
- Configure Codapi as systemd service:
sudo mv /opt/codapi/codapi.service /etc/systemd/system/
sudo chown root:root /etc/systemd/system/codapi.service
sudo systemctl enable codapi.service
sudo systemctl start codapi.service
Verify that the Codapi service is running:
sudo systemctl status codapi.service
Should print active (running):
codapi.service - Code playgrounds
Loaded: loaded (/etc/systemd/system/codapi.service; enabled; preset: enabled)
Active: active (running)
...
- Verify that Codapi is working:
curl -H "content-type: application/json" -d '{ "sandbox": "ash", "command": "run", "files": {"": "echo hello" }}' http://localhost:1313/v1/exec
Should print ok = true:
{
"id": "ash_run_dd27ed27",
"ok": true,
"duration": 650,
"stdout": "hello\n",
"stderr": ""
}