renminwansui1976 commited on
Commit
e8d0479
·
unverified ·
1 Parent(s): c4ead6a

更新 Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +37 -24
Dockerfile CHANGED
@@ -15,38 +15,49 @@ COPY src ./src
15
  RUN cargo build --release --locked
16
 
17
  # ── Stage 2: Runtime ───────────────────────────────────────────────────────────
18
- # Use the official Playwright image it has Chromium (required by OpenClaw's
19
- # browser-control features) and a compatible Node.js version pre-installed.
20
  FROM mcr.microsoft.com/playwright:v1.51.0-jammy AS runtime
21
 
22
  USER root
23
 
24
- # ── 2a. Install Node 22 (Playwright image ships Node 20; OpenClaw requires ≥22)
 
 
 
 
25
  RUN apt-get update \
26
- && apt-get install -y --no-install-recommends curl ca-certificates \
27
- && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
28
- && apt-get install -y --no-install-recommends nodejs \
 
29
  && rm -rf /var/lib/apt/lists/*
30
 
31
- # ── 2b. Install build tools required by openclaw's native deps + tini + Python
32
- RUN apt-get update \
33
- && apt-get install -y --no-install-recommends \
34
- tini \
35
- make cmake build-essential python3 python3-pip \
36
  && rm -rf /var/lib/apt/lists/*
37
 
38
- # ── 2c. Install OpenClaw globally (provides openclaw.mjs)
39
- RUN npm install -g openclaw@latest
 
 
 
 
 
 
 
 
 
40
 
41
- # ── 2d. Install LiteLLM proxy
42
- RUN pip3 install --no-cache-dir --break-system-packages "litellm[proxy]"
43
 
44
- # ── 2e. Copy Rust sync binary + startup script
45
  COPY --from=builder /app/target/release/openclaw-hf-sync /usr/local/bin/openclaw-hf-sync
46
  COPY start.sh /app/start.sh
47
  RUN chmod +x /usr/local/bin/openclaw-hf-sync /app/start.sh
48
 
49
- # ── 2f. Ensure OpenClaw data dir belongs to the runtime user (uid 1000)
50
  RUN set -eux; \
51
  if ! getent passwd 1000 >/dev/null; then \
52
  groupadd -g 1000 user; \
@@ -56,11 +67,13 @@ RUN set -eux; \
56
  chown -R 1000:1000 /home/user
57
 
58
  # ── Port config ────────────────────────────────────────────────────────────────
59
- # HF Space health-check expects port 7860.
60
- # OpenClaw listens on OPENCLAW_API_PORT; LiteLLM Proxy on 4000 (internal only).
 
61
  ENV OPENCLAW_API_PORT=7860 \
62
  OPENCLAW_WS_PORT=7861 \
63
- HOME=/home/user
 
64
 
65
  EXPOSE 7860 7861
66
 
@@ -68,9 +81,9 @@ WORKDIR /home/user/app
68
  USER 1000:1000
69
 
70
  # ── Entrypoint ─────────────────────────────────────────────────────────────────
71
- # openclaw-hf-sync:
72
- # 1. Pulls ~/.openclaw workspace from the HF dataset
73
- # 2. Spawns start.sh LiteLLM proxy (127.0.0.1:4000) + OpenClaw gateway
74
- # 3. Periodically pushes workspace changes back to HF dataset, and on shutdown
75
  ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/openclaw-hf-sync"]
76
  CMD ["/app/start.sh"]
 
15
  RUN cargo build --release --locked
16
 
17
  # ── Stage 2: Runtime ───────────────────────────────────────────────────────────
18
+ # Playwright jammy ships Chromium (required by OpenClaw's browser-control).
 
19
  FROM mcr.microsoft.com/playwright:v1.51.0-jammy AS runtime
20
 
21
  USER root
22
 
23
+ # ── 2a. System deps ────────────────────────────────────────────────────────────
24
+ # git : required by openclaw npm install (avoids "spawn git ENOENT")
25
+ # cmake/make/python3/build-essential : openclaw native deps (canvas, sharp, etc.)
26
+ # python3-venv : isolated LiteLLM install to avoid externally-managed-env errors
27
+ # tini : proper pid-1 signal forwarding
28
  RUN apt-get update \
29
+ && apt-get install -y --no-install-recommends \
30
+ git tini ca-certificates curl \
31
+ cmake make build-essential \
32
+ python3 python3-venv \
33
  && rm -rf /var/lib/apt/lists/*
34
 
35
+ # ── 2b. Install Node 22 (OpenClaw requires ≥22; Playwright ships Node 20) ─────
36
+ RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
37
+ && apt-get install -y --no-install-recommends nodejs \
 
 
38
  && rm -rf /var/lib/apt/lists/*
39
 
40
+ # ── 2c. Install OpenClaw globally ─────────────────────────────────────────────
41
+ # SHARP_IGNORE_GLOBAL_LIBVIPS=1 : skip system libvips check (avoids build fail)
42
+ # npm_config_cache=/tmp/npm-cache : writable cache dir during build
43
+ RUN SHARP_IGNORE_GLOBAL_LIBVIPS=1 \
44
+ npm_config_cache=/tmp/npm-cache \
45
+ npm install -g openclaw@latest \
46
+ && rm -rf /tmp/npm-cache
47
+
48
+ # ── 2d. Install LiteLLM into an isolated venv ─────────────────────────────────
49
+ RUN python3 -m venv /opt/litellm-venv \
50
+ && /opt/litellm-venv/bin/pip install --no-cache-dir "litellm[proxy]"
51
 
52
+ # Make litellm available on PATH
53
+ ENV PATH="/opt/litellm-venv/bin:$PATH"
54
 
55
+ # ── 2e. Copy Rust sync binary + startup script ────────────────────────────────
56
  COPY --from=builder /app/target/release/openclaw-hf-sync /usr/local/bin/openclaw-hf-sync
57
  COPY start.sh /app/start.sh
58
  RUN chmod +x /usr/local/bin/openclaw-hf-sync /app/start.sh
59
 
60
+ # ── 2f. Create runtime user (uid 1000) and openclaw data dir ──────────────────
61
  RUN set -eux; \
62
  if ! getent passwd 1000 >/dev/null; then \
63
  groupadd -g 1000 user; \
 
67
  chown -R 1000:1000 /home/user
68
 
69
  # ── Port config ────────────────────────────────────────────────────────────────
70
+ # HF Space health-check uses port 7860.
71
+ # OPENCLAW_API_PORT overrides OpenClaw's default (18789).
72
+ # LiteLLM proxy listens on 127.0.0.1:4000 (internal only).
73
  ENV OPENCLAW_API_PORT=7860 \
74
  OPENCLAW_WS_PORT=7861 \
75
+ HOME=/home/user \
76
+ SHARP_IGNORE_GLOBAL_LIBVIPS=1
77
 
78
  EXPOSE 7860 7861
79
 
 
81
  USER 1000:1000
82
 
83
  # ── Entrypoint ─────────────────────────────────────────────────────────────────
84
+ # openclaw-hf-sync (pid 1 via tini):
85
+ # 1. Pulls ~/.openclaw from the HF dataset
86
+ # 2. Spawns start.sh LiteLLM proxy + OpenClaw gateway
87
+ # 3. Pushes workspace changes back on a timer and on shutdown
88
  ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/openclaw-hf-sync"]
89
  CMD ["/app/start.sh"]