Skip to content

Commit 1190dee

Browse files
committed
feat: add gemini agent support and Docker-in-Docker auto-mount
- Add gemini.sh agent with oauth, api-key, vertex, and compute-adc auth - Auto-mount /var/run/docker.sock by default with --no-docker opt-out - Switch copilot-api to ericc-ch fork for latest features - Track gemini-cli, atlas-cli, and copilot-api versions in builds - Enhance version-report with colorized output and release dates - Reorganize Dockerfile for better cache reuse - Document container sandboxing architecture and Docker socket security
1 parent b3c91a5 commit 1190dee

12 files changed

Lines changed: 615 additions & 137 deletions

File tree

AGENTS.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
This file provides guidance to codex, Claude Code when working with code in this repository.
22

3+
## Deva Architecture: Container-Based Agent Sandboxing
4+
5+
**CRITICAL DESIGN PATTERN**: Deva purposely runs ALL agents inside Docker containers. The container IS the sandbox.
6+
7+
- Each agent (claude, codex, gemini) runs in isolated container environment
8+
- Agent internal sandboxes/permission systems are DISABLED:
9+
- claude: `--dangerously-skip-permissions`
10+
- gemini: `--yolo` flag
11+
- codex: equivalent unrestricted mode
12+
- Container provides security boundary instead of agent-level prompts
13+
- Result: No interactive permission prompts while maintaining isolation
14+
15+
**Why**: Avoids permission fatigue in trusted workspaces while keeping agents containerized for safety.
16+
317
## We're following Issue-Based Development (IBD) workflow
418
1. Before running any Git/GitHub CLI `Bash` command (`git commit`, `gh issue create`, `gh pr create`, etc.), open the corresponding file in @workflows to review required steps.
519
2. Always apply the exact templates or conventions from the following files:
@@ -121,6 +135,19 @@ Model aliases are automatically converted to appropriate formats (API model name
121135
- Requires explicit confirmation (`yes`) to proceed
122136
- Protects users from accidentally giving Claude access to all personal files
123137

138+
**Docker Socket Warning** (SECURITY-SENSITIVE):
139+
By default, `/var/run/docker.sock` is auto-mounted if present. This grants full Docker API access to the container - effectively equivalent to root on the host. The "container as sandbox" model is weakened when Docker socket is mounted.
140+
141+
Implications:
142+
- Agent can start/stop any container on host
143+
- Agent can mount any host path into new containers
144+
- Agent can escape to host via privileged container creation
145+
146+
Mitigations:
147+
- Use `--no-docker` flag to disable auto-mount
148+
- Set `DEVA_NO_DOCKER=1` environment variable
149+
- Only mount when Docker-in-Docker workflows are required
150+
124151
## Docker Architecture Details
125152

126153
### Volume Mounting Strategy

CLAUDE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
44

5+
## Deva Architecture: Container-Based Agent Sandboxing
6+
7+
**CRITICAL DESIGN PATTERN**: Deva purposely runs ALL agents inside Docker containers. The container IS the sandbox.
8+
9+
- Each agent (claude, codex, gemini) runs in isolated container environment
10+
- Agent internal sandboxes/permission systems are DISABLED (e.g., claude --dangerously-skip-permissions, GEMINI_SANDBOX=false)
11+
- Container provides security boundary instead of agent-level prompts
12+
- Result: No interactive permission prompts while maintaining isolation
13+
14+
**Why**: Avoids permission fatigue in trusted workspaces while keeping agents containerized for safety.
15+
516
## We're following Issue-Based Development (IBD) workflow
617
1. Before running any Git/GitHub CLI `Bash` command (`git commit`, `gh issue create`, `gh pr create`, etc.), open the corresponding file in @workflows to review required steps.
718
2. Always apply the exact templates or conventions from the following files:

DEV-LOGS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
- Reference issue numbers in the format `#<issue-number>` for easy linking.
1515

1616

17+
# [2025-11-27] Dev Log: Docker-in-Docker auto-mount support
18+
- Why: Common dev workflow need - testing containers, building images, CI/CD simulation inside deva environments
19+
- What: Auto-mount Docker socket (`/var/run/docker.sock`) by default with graceful detection, opt-out via `--no-docker` flag or `DEVA_NO_DOCKER=1`, quick permission fix (chmod 666) for deva user access
20+
- Result: DinD works out-of-box on Linux/macOS/WSL2, no manual socket mounting needed, aligns with YOLO philosophy (make it work, container is the boundary)
21+
1722
# [2025-10-26] Dev Log: Custom credential files via --auth-with
1823
- Why: Users have multiple credential files, needed direct path support beyond predefined auth methods
1924
- What: `--auth-with /path/to/creds.json` now works, auto-backup existing credentials, workspace session tracking in `~/.config/deva/sessions/*.json`

Dockerfile

Lines changed: 52 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
4848
RUN curl -fsSL https://bun.sh/install | bash && \
4949
ln -s /root/.bun/bin/bun /usr/local/bin/bun
5050

51-
# Install Copilot API branch with GPT-5 Codex responses support (caozhiyuan fork)
52-
# feature/responses-api adds: GPT-5-Codex support, model reasoning, token caching, enhanced streaming
53-
ARG COPILOT_API_REPO=https://github.com/caozhiyuan/copilot-api.git
54-
ARG COPILOT_API_BRANCH=feature/responses-api
55-
ARG COPILOT_API_COMMIT=83cdfde17d7d3be36bd2493cc7592ff13be4928d
56-
57-
RUN --mount=type=cache,target=/root/.npm,sharing=locked \
58-
npm install -g npm@latest pnpm && \
59-
git clone --branch "${COPILOT_API_BRANCH}" "${COPILOT_API_REPO}" /tmp/copilot-api && \
60-
cd /tmp/copilot-api && \
61-
git checkout "${COPILOT_API_COMMIT}" && \
62-
git log --oneline -5 && \
63-
bun install --frozen-lockfile && bun run build && \
64-
cd /tmp && npm install -g --ignore-scripts /tmp/copilot-api && \
65-
rm -rf /tmp/copilot-api && \
66-
npm cache clean --force
67-
51+
# Install stable runtimes BEFORE volatile packages to maximize cache reuse
6852
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
6953

7054
# Pre-install Python 3.14t (free-threaded) for uv
@@ -77,6 +61,26 @@ RUN --mount=type=cache,target=/tmp/go-cache,sharing=locked \
7761
wget -q https://go.dev/dl/go1.22.0.linux-${GO_ARCH}.tar.gz && \
7862
tar -C /usr/local -xzf go1.22.0.linux-${GO_ARCH}.tar.gz
7963

64+
# Install Copilot API (ericc-ch fork with latest features)
65+
# Placed at end of runtimes stage to avoid invalidating cache for stable runtimes
66+
ARG COPILOT_API_REPO=https://github.com/ericc-ch/copilot-api.git
67+
ARG COPILOT_API_BRANCH=master
68+
ARG COPILOT_API_COMMIT=master
69+
ARG COPILOT_API_VERSION
70+
71+
LABEL org.opencontainers.image.copilot_api_version=${COPILOT_API_VERSION}
72+
73+
RUN --mount=type=cache,target=/root/.npm,sharing=locked \
74+
npm install -g npm@latest pnpm && \
75+
git clone --branch "${COPILOT_API_BRANCH}" "${COPILOT_API_REPO}" /tmp/copilot-api && \
76+
cd /tmp/copilot-api && \
77+
git checkout "${COPILOT_API_COMMIT}" && \
78+
git log --oneline -5 && \
79+
bun install --frozen-lockfile && bun run build && \
80+
cd /tmp && npm install -g --ignore-scripts /tmp/copilot-api && \
81+
rm -rf /tmp/copilot-api && \
82+
npm cache clean --force
83+
8084
FROM runtimes AS cloud-tools
8185

8286
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
@@ -146,31 +150,12 @@ RUN mkdir -p "$DEVA_HOME/.npm-global" && \
146150

147151
# Set npm configuration for deva user and install CLI tooling
148152
USER $DEVA_USER
149-
ARG CLAUDE_CODE_VERSION
150-
ARG CODEX_VERSION
151-
152-
# Record key tool versions as labels for quick inspection
153-
LABEL org.opencontainers.image.claude_code_version=${CLAUDE_CODE_VERSION}
154-
LABEL org.opencontainers.image.codex_version=${CODEX_VERSION}
155153

156154
# Speed up npm installs and avoid noisy audits/funds prompts
157155
ENV NPM_CONFIG_AUDIT=false \
158156
NPM_CONFIG_FUND=false
159157

160-
# Use BuildKit cache for npm to speed up repeated builds
161-
RUN --mount=type=cache,target=/home/deva/.npm,uid=${DEVA_UID},gid=${DEVA_GID},sharing=locked \
162-
npm config set prefix "$DEVA_HOME/.npm-global" && \
163-
npm install -g --no-audit --no-fund \
164-
@anthropic-ai/claude-code@${CLAUDE_CODE_VERSION} \
165-
@mariozechner/claude-trace \
166-
@openai/codex@${CODEX_VERSION} && \
167-
npm cache clean --force && \
168-
npm list -g --depth=0 @anthropic-ai/claude-code @openai/codex || true
169-
170-
# Install Go tools for Atlassian integration (Confluence/Jira/Bitbucket)
171-
RUN go install github.com/lroolle/atlas-cli/cmd/atl@5f6a20c4d164bf6fe6f5c60f9ac12dfccf210758 && \
172-
sudo mv $HOME/go/bin/atl /usr/local/bin/
173-
158+
# Install stable components BEFORE ARG declarations to maximize cache reuse
174159
RUN git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh "$DEVA_HOME/.oh-my-zsh" && \
175160
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions "$DEVA_HOME/.oh-my-zsh/custom/plugins/zsh-autosuggestions" && \
176161
git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git "$DEVA_HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting"
@@ -186,6 +171,36 @@ RUN echo 'export ZSH="$HOME/.oh-my-zsh"' > "$DEVA_HOME/.zshrc" && \
186171
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
187172
$DEVA_HOME/.local/bin/uv python install 3.14t
188173

174+
# Declare ARGs immediately before usage to minimize cache invalidation
175+
ARG CLAUDE_CODE_VERSION
176+
ARG CODEX_VERSION
177+
ARG GEMINI_CLI_VERSION=latest
178+
179+
# Record key tool versions as labels for quick inspection
180+
LABEL org.opencontainers.image.claude_code_version=${CLAUDE_CODE_VERSION}
181+
LABEL org.opencontainers.image.codex_version=${CODEX_VERSION}
182+
LABEL org.opencontainers.image.gemini_cli_version=${GEMINI_CLI_VERSION}
183+
184+
# Use BuildKit cache for npm to speed up repeated builds
185+
RUN --mount=type=cache,target=/home/deva/.npm,uid=${DEVA_UID},gid=${DEVA_GID},sharing=locked \
186+
npm config set prefix "$DEVA_HOME/.npm-global" && \
187+
npm install -g --no-audit --no-fund \
188+
@anthropic-ai/claude-code@${CLAUDE_CODE_VERSION} \
189+
@mariozechner/claude-trace \
190+
@openai/codex@${CODEX_VERSION} \
191+
@google/gemini-cli@${GEMINI_CLI_VERSION} && \
192+
npm cache clean --force && \
193+
npm list -g --depth=0 @anthropic-ai/claude-code @openai/codex @google/gemini-cli || true
194+
195+
# Volatile packages: Install at the end to avoid cascading rebuilds
196+
ARG ATLAS_CLI_VERSION=main
197+
198+
LABEL org.opencontainers.image.atlas_cli_version=${ATLAS_CLI_VERSION}
199+
200+
# Install Go tools for Atlassian integration (Confluence/Jira/Bitbucket)
201+
RUN go install github.com/lroolle/atlas-cli/cmd/atl@${ATLAS_CLI_VERSION} && \
202+
sudo mv $HOME/go/bin/atl /usr/local/bin/
203+
189204
USER root
190205

191206
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh

0 commit comments

Comments
 (0)