mirror of
https://github.com/yashshah9/agentbox.git
synced 2026-11-18 18:03:44 +00:00
feat(docker): runtime-docker image and compose.docker-sandbox overlay
Context: - Docker sandbox backend needed docker-cli in the image and a same-path TMPDIR bind-mount for nested docker run -v on Docker Desktop. - Without a compose path, agentforge and ops users stayed on subprocess. Test Plan: - AGENTBOX_HOST_TMP=$PWD/.agentbox-work docker compose -f compose.yaml \ -f compose.docker-sandbox.yaml up --build -d agentbox - curl /health shows backend=docker; POST /v1/run with network_isolated=true Additional Notes: - Default compose remains subprocess for simple CI/unit use.
This commit is contained in:
@@ -2,3 +2,4 @@ __pycache__/
|
||||
.venv/
|
||||
.pytest_cache/
|
||||
dist/
|
||||
.agentbox-work/
|
||||
|
||||
@@ -125,11 +125,19 @@ client.close()
|
||||
## Docker
|
||||
|
||||
```bash
|
||||
docker compose up agentbox # start API on :8080
|
||||
docker compose run --rm test # run unit tests
|
||||
docker compose up agentbox # start API on :8080 (subprocess backend)
|
||||
docker compose run --rm test # unit tests
|
||||
```
|
||||
|
||||
Note: using `AGENTBOX_SANDBOX_BACKEND=docker` from inside a container needs Docker socket access (DinD / mounted socket). Prefer running the API on the host with the Docker backend, or keep the compose service on `subprocess`.
|
||||
### Compose + Docker sandbox backend
|
||||
|
||||
```bash
|
||||
export AGENTBOX_HOST_TMP="$(pwd)/.agentbox-work"
|
||||
mkdir -p "$AGENTBOX_HOST_TMP"
|
||||
docker compose -f compose.yaml -f compose.docker-sandbox.yaml up --build agentbox
|
||||
```
|
||||
|
||||
Uses image target `runtime-docker` (`docker-cli` + `AGENTBOX_SANDBOX_BACKEND=docker`), mounts the Docker socket, and bind-mounts `AGENTBOX_HOST_TMP` at the **same absolute path** so nested `docker run -v` works on Docker Desktop.
|
||||
|
||||
## Configuration
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# Use: mkdir -p "$AGENTBOX_HOST_TMP" && \
|
||||
# AGENTBOX_HOST_TMP="$(pwd)/.agentbox-work" \
|
||||
# docker compose -f compose.yaml -f compose.docker-sandbox.yaml up --build agentbox
|
||||
services:
|
||||
agentbox:
|
||||
build:
|
||||
target: runtime-docker
|
||||
environment:
|
||||
AGENTBOX_SANDBOX_BACKEND: docker
|
||||
TMPDIR: ${AGENTBOX_HOST_TMP:?Set AGENTBOX_HOST_TMP to an absolute host path}
|
||||
AGENTBOX_SNAPSHOT_DIR: ${AGENTBOX_HOST_TMP}/snapshots
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- ${AGENTBOX_HOST_TMP}:${AGENTBOX_HOST_TMP}
|
||||
@@ -17,3 +17,10 @@ RUN pip install --no-cache-dir .
|
||||
EXPOSE 8080
|
||||
HEALTHCHECK CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health')"
|
||||
CMD ["agentbox", "serve", "--host", "0.0.0.0", "--port", "8080"]
|
||||
|
||||
# Docker sandbox backend: needs docker CLI + mounted docker.sock (see compose profile).
|
||||
# Nested `docker run -v` requires TMPDIR bind-mounted at the same absolute host path.
|
||||
FROM runtime AS runtime-docker
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends docker-cli \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
ENV AGENTBOX_SANDBOX_BACKEND=docker
|
||||
|
||||
Reference in New Issue
Block a user