-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.worker
More file actions
63 lines (53 loc) · 3.86 KB
/
Copy pathDockerfile.worker
File metadata and controls
63 lines (53 loc) · 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
FROM python:3.12-slim
# ── System deps ──────────────────────────────────────────────────────────────
# Node.js 22 is required to install and run Claude Code CLI
RUN apt-get update && apt-get install -y --no-install-recommends \
git curl ca-certificates gnupg build-essential \
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/*
# ── Coding-agent CLIs (one per supported vendor) ───────────────────────────────
# Each task picks a vendor (anthropic/google/openai/glm); the worker shells out
# to that vendor's CLI, so all of them must be on $PATH inside the image. A task
# whose vendor CLI is missing now fails fast with an actionable
# "<Vendor> CLI not found" message (see services/agent_backends.is_available).
# - anthropic → claude (@anthropic-ai/claude-code)
# - google → gemini (@google/gemini-cli)
# - openai → codex (@openai/codex)
# - glm → glm (xqsit94/glm launcher — wraps Claude Code for Zhipu)
RUN npm install -g @anthropic-ai/claude-code @google/gemini-cli @openai/codex
# glm is a curl|bash launcher (not npm). It writes to ~/.local/bin and edits
# shell rc files — neither of which is on PATH for the non-interactive CMD — so
# we symlink it into /usr/local/bin. Best-effort: a failed install must not break
# the image; glm tasks then fail fast at runtime with a "GLM CLI not found"
# message instead.
ENV PATH="/root/.local/bin:${PATH}"
RUN (curl -fsSL https://raw.githubusercontent.com/xqsit94/glm/main/install.sh | bash) \
&& { [ -x /root/.local/bin/glm ] && ln -sf /root/.local/bin/glm /usr/local/bin/glm || true; } \
|| echo "WARNING: glm CLI install failed — glm-vendor tasks will report 'not installed' at runtime"
# ── Git global identity ──────────────────────────────────────────────────────
# Defaults that work out of the box. Override via GIT_USER_EMAIL / GIT_USER_NAME
# in your .env and the worker will reapply the identity to each worktree.
RUN git config --global user.email "devserver@devserver.local" \
&& git config --global user.name "DevServer Agent" \
&& git config --global init.defaultBranch main \
&& git config --global safe.directory '*'
# ── Python app ───────────────────────────────────────────────────────────────
WORKDIR /app
COPY apps/worker/pyproject.toml ./
RUN pip install --no-cache-dir .
# ── Pre-download the local embedding model ───────────────────────────────────
# Bakes the fastembed model into the image so the first memory recall runs
# offline-clean (no download at runtime). Must match EMBEDDING_MODEL in .env.
ARG EMBEDDING_MODEL=BAAI/bge-base-en-v1.5
ENV EMBEDDING_MODEL=${EMBEDDING_MODEL}
RUN python -c "from fastembed import TextEmbedding; TextEmbedding(model_name='${EMBEDDING_MODEL}')"
COPY apps/worker/src/ ./src/
COPY .claude/skills/ ./.claude/skills/
# ── Runtime dirs ─────────────────────────────────────────────────────────────
RUN mkdir -p worktrees/.bare logs/tasks
ENV PYTHONPATH=/app/src
EXPOSE 8000
# tee stdout/stderr into /app/logs/worker.log so the in-app /logs viewer
# (which tails the file) works inside docker too.
CMD ["sh", "-c", "mkdir -p /app/logs && uvicorn src.main:app --host 0.0.0.0 --port 8000 2>&1 | tee -a /app/logs/worker.log"]