|
1 | 1 | # docker-git |
2 | 2 |
|
3 | | -`docker-git` generates a disposable Docker development environment per repository (or empty workspace) and stores it under a single projects root (default: `~/.docker-git`). |
| 3 | +`docker-git` создаёт отдельную Docker-среду для каждого репозитория, issue или PR. |
| 4 | +По умолчанию проекты лежат в `~/.docker-git`. |
4 | 5 |
|
5 | | -Key goals: |
6 | | -- Functional Core, Imperative Shell implementation (pure templates + typed orchestration). |
7 | | -- Per-project `.orch/` directory (env + local state), while still allowing shared credentials across containers. |
8 | | -- Shared package caches (`pnpm`/`npm`/`yarn`) across all project containers. |
9 | | -- Optional Playwright MCP + Chromium sidecar so Codex and Claude Code can do browser automation. |
| 6 | +## Что нужно |
10 | 7 |
|
11 | | -## Quickstart |
| 8 | +- Docker Engine или Docker Desktop |
| 9 | +- Доступ к Docker без `sudo` |
| 10 | +- Node.js и `npm` |
12 | 11 |
|
13 | | -From this repo: |
| 12 | +## Установка |
14 | 13 |
|
15 | 14 | ```bash |
16 | | -pnpm install |
17 | | - |
18 | | -# Interactive TUI menu (default) |
19 | | -pnpm run docker-git |
20 | | - |
21 | | -# Create an empty workspace container (no git clone) |
22 | | -pnpm run docker-git create |
| 15 | +npm i -g @prover-coder-ai/docker-git |
| 16 | +docker-git --help |
| 17 | +``` |
23 | 18 |
|
24 | | -# Clone a repo into its own container (creates under ~/.docker-git) |
25 | | -pnpm run docker-git clone https://github.com/agiens/crm/tree/vova-fork --force |
| 19 | +## Авторизация |
26 | 20 |
|
27 | | -# Clone an issue URL (creates isolated workspace + issue branch) |
28 | | -pnpm run docker-git clone https://github.com/agiens/crm/issues/123 --force |
| 21 | +```bash |
| 22 | +docker-git auth github login --web |
| 23 | +docker-git auth codex login --web |
| 24 | +docker-git auth claude login --web |
| 25 | +``` |
29 | 26 |
|
30 | | -# Open an existing docker-git project by repo/issue URL (runs up + tmux attach) |
31 | | -pnpm run docker-git open https://github.com/agiens/crm/issues/123 |
| 27 | +## Пример |
32 | 28 |
|
33 | | -# Reset only project env defaults (keep workspace volume/data) |
34 | | -pnpm run docker-git clone https://github.com/agiens/crm/issues/123 --force-env |
| 29 | +Можно передавать ссылку на репозиторий, ветку (`/tree/...`), issue или PR. |
35 | 30 |
|
36 | | -# Same, but also enable Playwright MCP + Chromium sidecar for Codex/Claude |
37 | | -pnpm run docker-git clone https://github.com/agiens/crm/tree/vova-fork --force --mcp-playwright |
| 31 | +```bash |
| 32 | +docker-git clone https://github.com/ProverCoderAI/docker-git/issues/122 --force --mcp-playwright |
38 | 33 | ``` |
39 | 34 |
|
40 | | -## API Docker (separate runtime) |
| 35 | +- `--force` пересоздаёт окружение и удаляет volumes проекта. |
| 36 | +- `--mcp-playwright` включает Playwright MCP и Chromium sidecar для браузерной автоматизации. |
41 | 37 |
|
42 | | -HTTP API (`packages/api`) has a dedicated Docker image and compose file: |
| 38 | +Автоматический запуск агента: |
43 | 39 |
|
44 | 40 | ```bash |
45 | | -docker compose -f docker-compose.api.yml up -d --build |
46 | | -curl -s http://127.0.0.1:3334/health |
| 41 | +docker-git clone https://github.com/ProverCoderAI/docker-git/issues/122 --force --auto |
47 | 42 | ``` |
48 | 43 |
|
49 | | -By default API port `3334` is published to host (`127.0.0.1:3334`). |
50 | | - |
51 | | -Useful env overrides: |
52 | | -- `DOCKER_GIT_API_BIND_HOST` (default: `127.0.0.1`) |
53 | | -- `DOCKER_GIT_API_PORT` (default: `3334`) |
54 | | -- `DOCKER_GIT_PROJECTS_ROOT_HOST` (host path, default: `/home/dev/.docker-git`) |
55 | | -- `DOCKER_GIT_PROJECTS_ROOT` (container path, default: `/home/dev/.docker-git`) |
56 | | - |
57 | | -Detailed federation subscription workflow and JSON examples are documented in `packages/api/README.md`. |
58 | | - |
59 | | -## Parallel Issues / PRs |
60 | | - |
61 | | -When you clone GitHub issue or PR URLs, docker-git creates isolated project paths and container names: |
62 | | -- `.../issues/123` -> `<projectsRoot>/<owner>/<repo>/issue-123` (branch `issue-123`) |
63 | | -- `.../pull/45` -> `<projectsRoot>/<owner>/<repo>/pr-45` (ref `refs/pull/45/head`) |
64 | | - |
65 | | -This lets you run multiple issues/PRs for the same repository in parallel without container/path collisions. |
66 | | - |
67 | | -Force modes: |
68 | | -- `--force`: overwrite managed files and wipe compose volumes (`docker compose down -v`). |
69 | | -- `--force-env`: reset only project env defaults and recreate containers without wiping volumes. |
70 | | - |
71 | | -Agent context for issue workspaces: |
72 | | -- Global `${CODEX_HOME}/AGENTS.md` includes workspace path + issue/PR context. |
73 | | - |
74 | | -## Projects Root Layout |
75 | | - |
76 | | -The projects root is: |
77 | | -- `~/.docker-git` by default |
78 | | -- Override with `DOCKER_GIT_PROJECTS_ROOT=/some/path` |
79 | | - |
80 | | -Structure (simplified): |
81 | | - |
82 | | -```text |
83 | | -~/.docker-git/ |
84 | | - authorized_keys |
85 | | - .orch/ |
86 | | - env/ |
87 | | - global.env # shared tokens/keys (GitHub, Git, Claude) with labels |
88 | | - auth/ |
89 | | - codex/ # shared Codex auth/config (when CODEX_SHARE_AUTH=1) |
90 | | - gh/ # GH CLI auth cache for OAuth login container |
91 | | - .cache/ |
92 | | - git-mirrors/ # shared git clone mirrors |
93 | | - packages/ # shared pnpm/npm/yarn caches |
94 | | - <owner>/<repo>/ |
95 | | - docker-compose.yml |
96 | | - Dockerfile |
97 | | - entrypoint.sh |
98 | | - docker-git.json |
99 | | - .orch/ |
100 | | - env/ |
101 | | - project.env # per-project env knobs (see below) |
102 | | - auth/ |
103 | | - codex/ # project-local Codex state (sessions/logs/tmp/etc) |
104 | | -``` |
| 44 | +- `--auto` сам выбирает Claude или Codex по доступной авторизации. Если доступны оба, выбор случайный. |
| 45 | +- `--auto=claude` или `--auto=codex` принудительно выбирает агента. |
| 46 | +- В auto-режиме агент сам выполняет задачу, создаёт PR и после завершения контейнер очищается. |
| 47 | + |
| 48 | +## Подробности |
105 | 49 |
|
106 | | -## Codex Auth: Shared Credentials, Per-Project Sessions |
107 | | - |
108 | | -Default behavior: |
109 | | -- Shared credentials live in `/home/dev/.codex-shared/auth.json` (mounted from `<projectsRoot>/.orch/auth/codex`). |
110 | | -- Each project keeps its own Codex state under `/home/dev/.codex/` (mounted from project `.orch/auth/codex`). |
111 | | -- The entrypoint links `/home/dev/.codex/auth.json -> /home/dev/.codex-shared/auth.json`. |
112 | | - |
113 | | -This avoids `refresh_token` rotation issues that can happen when copying `auth.json` into every project while still keeping session state isolated per project. |
114 | | - |
115 | | -Disable sharing (per-project auth): |
116 | | -- Set `CODEX_SHARE_AUTH=0` in `.orch/env/project.env`. |
117 | | - |
118 | | -## Claude Code Defaults |
119 | | - |
120 | | -On container start, docker-git syncs Claude Code user settings under `$CLAUDE_CONFIG_DIR/settings.json`: |
121 | | -- `permissions.defaultMode = "bypassPermissions"` so local disposable containers behave like docker-git Codex containers (no permission prompts). |
122 | | -- Existing unrelated Claude settings are preserved. |
123 | | - |
124 | | -## Playwright MCP (Chromium Sidecar) |
125 | | - |
126 | | -Enable during create/clone: |
127 | | -- Add `--mcp-playwright` |
128 | | - |
129 | | -Enable for an existing project directory (preserves `.orch/env/project.env` and volumes): |
130 | | -- `docker-git mcp-playwright [<url>] [--project-dir <path>]` |
131 | | - |
132 | | -This will: |
133 | | -- Create a Chromium sidecar container: `dg-<repo>-browser` |
134 | | -- Configure Codex MCP server `playwright` inside the dev container |
135 | | -- Configure Claude Code MCP server `playwright` inside `$CLAUDE_CONFIG_DIR/.claude.json` |
136 | | -- Provide a wrapper `docker-git-playwright-mcp` inside the dev container |
137 | | - |
138 | | -Template attribute behavior: |
139 | | -- `--mcp-playwright` sets `enableMcpPlaywright=true` in `docker-git.json`. |
140 | | -- On container start, docker-git syncs Playwright MCP config for both Codex and Claude based on this attribute/env. |
141 | | - |
142 | | -Concurrency (many Codex sessions): |
143 | | -- Default is safe for many sessions: `MCP_PLAYWRIGHT_ISOLATED=1` |
144 | | -- Each Codex session gets its own browser context (incognito) to reduce cross-session interference. |
145 | | -- If you want a shared browser context (shared cookies/login), set `MCP_PLAYWRIGHT_ISOLATED=0` (not recommended with multiple concurrent sessions). |
146 | | - |
147 | | -## Runtime Env Knobs (per project) |
148 | | - |
149 | | -Edit: `<projectDir>/.orch/env/project.env` |
150 | | - |
151 | | -Common toggles: |
152 | | -- `CODEX_SHARE_AUTH=1|0` (default: `1`) |
153 | | -- `CODEX_AUTO_UPDATE=1|0` (default: `1`) |
154 | | -- `CLAUDE_AUTO_SYSTEM_PROMPT=1|0` (default: `1`, auto-attach managed system prompt to `claude`) |
155 | | -- `DOCKER_GIT_ZSH_AUTOSUGGEST=1|0` (default: `1`) |
156 | | -- `MCP_PLAYWRIGHT_ISOLATED=1|0` (default: `1`) |
157 | | -- `MCP_PLAYWRIGHT_CDP_ENDPOINT=http://...` (override CDP endpoint if needed) |
158 | | -- `PNPM_STORE_DIR=/home/dev/.docker-git/.cache/packages/pnpm/store` (default shared store) |
159 | | -- `NPM_CONFIG_CACHE=/home/dev/.docker-git/.cache/packages/npm` (default shared cache) |
160 | | -- `YARN_CACHE_FOLDER=/home/dev/.docker-git/.cache/packages/yarn` (default shared cache) |
161 | | - |
162 | | -## Compose Network Mode |
163 | | - |
164 | | -Default mode is shared: |
165 | | -- `--network-mode shared` (default) |
166 | | -- Shared compose network name: `--shared-network docker-git-shared` |
167 | | - |
168 | | -Shared mode keeps one external Docker network for all docker-git projects, which reduces address pool pressure when many projects are created. |
169 | | - |
170 | | -If you need strict per-project isolation: |
171 | | -- `--network-mode project` |
172 | | - |
173 | | -In project mode, each project uses `<service>-net` (Docker-managed bridge network). |
174 | | - |
175 | | -## Troubleshooting |
176 | | - |
177 | | -MCP errors in `codex` UI: |
178 | | -- `No such file or directory (os error 2)` for `playwright`: |
179 | | - - `~/.codex/config.toml` contains `[mcp_servers.playwright]`, but the container was created without `--mcp-playwright`. |
180 | | - - Fix (recommended): run `docker-git mcp-playwright [<url>]` to enable it for the existing project. |
181 | | - - Fix (recreate): recreate with `--force-env --mcp-playwright` (keeps volumes) or `--force --mcp-playwright` (wipes volumes). |
182 | | -- `handshaking ... initialize response`: |
183 | | - - The configured MCP command is not a real MCP server (example: `command="echo"`). |
184 | | - |
185 | | -MCP errors in `claude` UI: |
186 | | -- `MCP server "playwright" not found`: |
187 | | - - The container/project was created without `--mcp-playwright` (or `enableMcpPlaywright=false` in `docker-git.json`). |
188 | | - - Fix: run `docker-git mcp-playwright [<url>]` or recreate/apply with `--mcp-playwright`. |
189 | | - |
190 | | -Docker permission error (`/var/run/docker.sock`): |
191 | | -- Symptom: |
192 | | - - `permission denied while trying to connect to the docker API at unix:///var/run/docker.sock` |
193 | | -- Check: |
194 | | - ```bash |
195 | | - id |
196 | | - ls -l /var/run/docker.sock |
197 | | - docker version |
198 | | - ``` |
199 | | -- Fix (works in `fish` and `bash`): |
200 | | - ```bash |
201 | | - sudo chgrp docker /var/run/docker.sock |
202 | | - sudo chmod 660 /var/run/docker.sock |
203 | | - sudo mkdir -p /etc/systemd/system/docker.socket.d |
204 | | - printf '[Socket]\nSocketGroup=docker\nSocketMode=0660\n' | sudo tee /etc/systemd/system/docker.socket.d/override.conf >/dev/null |
205 | | - sudo systemctl daemon-reload |
206 | | - sudo systemctl restart docker.socket docker |
207 | | - ``` |
208 | | -- Verify: |
209 | | - ```bash |
210 | | - ls -l /var/run/docker.sock |
211 | | - docker version |
212 | | - ``` |
213 | | -- Note: |
214 | | - - Do not run `pnpm run docker-git ...` with `sudo`. |
215 | | - |
216 | | -Docker network pool exhausted (`all predefined address pools have been fully subnetted`): |
217 | | -- Symptom: |
218 | | - - `failed to create network ... all predefined address pools have been fully subnetted` |
219 | | -- Quick recovery: |
220 | | - ```bash |
221 | | - docker network prune -f |
222 | | - ``` |
223 | | -- Long-term fix: |
224 | | - - Configure Docker daemon `default-address-pools` in `/etc/docker/daemon.json`. |
225 | | - - Prefer `docker-git` shared network mode (`--network-mode shared`). |
226 | | - |
227 | | -Clone auth error (`Invalid username or token`): |
228 | | -- Symptom: |
229 | | - - `remote: Invalid username or token. Password authentication is not supported for Git operations.` |
230 | | -- Check and fix token: |
231 | | - ```bash |
232 | | - pnpm run docker-git auth github status |
233 | | - pnpm run docker-git auth github logout |
234 | | - pnpm run docker-git auth github login --web |
235 | | - pnpm run docker-git auth github status |
236 | | - ``` |
237 | | -- Token requirements: |
238 | | - - Token must have access to the target repository. |
239 | | - - For org repositories with SSO/SAML, authorize the token for that organization. |
240 | | - - Recommended scopes: `repo,workflow,read:org`. |
241 | | - |
242 | | -## Security Notes |
243 | | - |
244 | | -The generated Codex config uses: |
245 | | -- `sandbox_mode = "danger-full-access"` |
246 | | -- `approval_policy = "never"` |
247 | | - |
248 | | -This is intended for local disposable containers. Do not reuse these defaults for untrusted code. |
| 50 | +`docker-git --help` |
0 commit comments