renminwansui1976 commited on
Commit
e0b8344
·
unverified ·
1 Parent(s): 6f503f1

更新 Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +40 -23
Dockerfile CHANGED
@@ -5,7 +5,8 @@ FROM rust:1.94.0-slim-bookworm AS builder
5
  WORKDIR /app
6
 
7
  RUN apt-get update \
8
- && apt-get install -y --no-install-recommends build-essential pkg-config ca-certificates \
 
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
  COPY Cargo.toml ./
@@ -13,47 +14,63 @@ COPY Cargo.lock ./
13
  COPY src ./src
14
  RUN cargo build --release --locked
15
 
16
- # ── Stage 2: Runtime ──────────────────────────────────────────────────────────
17
- # Base: OpenClaw official image (Node 22 + openclaw.mjs)
18
- FROM ghcr.io/openclaw/openclaw:latest AS runtime
 
19
 
20
  USER root
21
 
22
- # Install: tini (pid1), curl (health-check), Python 3 + pip (LiteLLM)
 
 
 
 
 
 
 
23
  RUN apt-get update \
24
  && apt-get install -y --no-install-recommends \
25
- tini ca-certificates curl \
26
- python3 python3-pip \
27
- && pip3 install --no-cache-dir --break-system-packages litellm[proxy] \
28
  && rm -rf /var/lib/apt/lists/*
29
 
30
- # Copy Rust sync binary
31
- COPY --from=builder /app/target/release/openclaw-hf-sync /usr/local/bin/openclaw-hf-sync
32
- RUN chmod +x /usr/local/bin/openclaw-hf-sync
 
 
33
 
34
- # Copy startup script
 
35
  COPY start.sh /app/start.sh
36
- RUN chmod +x /app/start.sh
37
 
38
- # Ensure OpenClaw data dir belongs to the node user (uid 1000)
39
- RUN mkdir -p /home/node/.openclaw && chown -R node:node /home/node/.openclaw
 
 
 
 
 
 
40
 
41
- # ── Port config ───────────────────────────────────────────────────────────────
42
  # HF Space health-check expects port 7860.
43
- # OpenClaw listens on OPENCLAW_API_PORT; LiteLLM proxy on 4000 (internal only).
44
  ENV OPENCLAW_API_PORT=7860 \
45
  OPENCLAW_WS_PORT=7861 \
46
- HOME=/home/node
47
 
48
  EXPOSE 7860 7861
49
 
50
- WORKDIR /app
51
- USER node
52
 
53
- # ── Entrypoint ────────────────────────────────────────────────────────────────
54
  # openclaw-hf-sync:
55
  # 1. Pulls ~/.openclaw workspace from the HF dataset
56
- # 2. Spawns start.sh (LiteLLM proxy OpenClaw gateway)
57
- # 3. Periodically pushes workspace changes back, and on shutdown
58
  ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/openclaw-hf-sync"]
59
  CMD ["/app/start.sh"]
 
5
  WORKDIR /app
6
 
7
  RUN apt-get update \
8
+ && apt-get install -y --no-install-recommends \
9
+ build-essential pkg-config ca-certificates \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
  COPY Cargo.toml ./
 
14
  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; \
53
+ useradd -m -u 1000 -g 1000 -s /bin/bash user; \
54
+ fi; \
55
+ mkdir -p /home/user/.openclaw /home/user/app; \
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
 
67
+ 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.shLiteLLM 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"]