-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docker_runtime based on eventstream
Provided working example files for building and running custom sandbox using the DockerRuntime.
- Loading branch information
Showing
8 changed files
with
608 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# | ||
local | ||
|
||
build.sh | ||
compose.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# How to build custom Docker sandbox for OpenHands | ||
|
||
[Docker](https://docs.docker.com/get-started/docker-overview/) is an open platform for developing, shipping, and running applications. | ||
|
||
This folder contains working examples to get you started. | ||
|
||
## Build the sandbox | ||
|
||
```bash | ||
# rename the files and make changes as you please | ||
cp build.example.sh build.sh | ||
cp compose.example.yml compose.yml | ||
|
||
./build.sh <my base image> | ||
``` | ||
|
||
## Start up sandbox | ||
|
||
```bash | ||
docker compose up -d | ||
``` | ||
|
||
## Update config.toml and restart OpenHands | ||
|
||
```toml | ||
[core] | ||
runtime="docker" | ||
|
||
[sandbox] | ||
container_name="<sandbox container_name>" | ||
remote_runtime_api_url="http://<host>:<published sandbox port>/" | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
### | ||
OPENHANDS_WORKSPACE=$(git rev-parse --show-toplevel) | ||
|
||
cd "$OPENHANDS_WORKSPACE/" || exit 1 | ||
|
||
# custom sandbox base image | ||
IMAGE="${1:-nikolaik/python-nodejs:python3.12-nodejs22}" | ||
# custom sandbox image tag | ||
TAG="${2:-custom-sandbox:latest}" | ||
|
||
mkdir -p "$OPENHANDS_WORKSPACE/containers/custom-sandbox/local" | ||
|
||
poetry run python3 openhands/runtime/utils/runtime_build.py \ | ||
--base_image "$IMAGE" \ | ||
--build_folder ./containers/custom-sandbox/local | ||
|
||
docker buildx build \ | ||
--progress "plain" \ | ||
--tag "$TAG" \ | ||
--load \ | ||
./containers/custom-sandbox/local | ||
|
||
### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
### | ||
name: sandbox | ||
services: | ||
sandbox: | ||
# The container_name must match the name defined in the config.toml | ||
container_name: custom-sandbox | ||
privileged: true | ||
build: | ||
context: ./local | ||
dockerfile: Dockerfile | ||
image: custom-sandbox | ||
command: > | ||
/openhands/micromamba/bin/micromamba run -n openhands | ||
poetry run | ||
python -u -m openhands.runtime.action_execution_server 3000 | ||
--working-dir /workspace | ||
--plugins agent_skills jupyter | ||
--username openhands | ||
# the publicly exposed port 8000 must match the port in remote_runtime_api_url defined in the config.toml | ||
ports: | ||
- "8000:3000" | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
- workspace-data:/workspace | ||
pull_policy: never | ||
|
||
## | ||
volumes: | ||
workspace-data: | ||
|
||
### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[core] | ||
runtime="docker" | ||
|
||
[sandbox] | ||
container_name="custom-sandbox" | ||
remote_runtime_api_url="http://host.docker.internal:8000/" | ||
|
||
docker_url="unix:///var/run/docker.sock" | ||
|
||
### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.