renminwansui1976 commited on
Commit
9c9e8e9
·
unverified ·
1 Parent(s): ba6dbbc

更新 Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -24
Dockerfile CHANGED
@@ -11,26 +11,24 @@ RUN apt-get update \
11
 
12
  COPY Cargo.toml ./
13
  COPY src ./src
14
- # Do not copy Cargo.lock — let Cargo resolve a fresh consistent lockfile.
15
- # (Our hand-edited Cargo.lock drifted from Cargo.toml, causing --locked to fail.)
16
  RUN cargo build --release
17
 
18
  # ── Stage 2: Runtime ───────────────────────────────────────────────────────────
19
- # Playwright jammy ships Chromium (required by OpenClaw's browser-control).
20
  FROM mcr.microsoft.com/playwright:v1.51.0-jammy AS runtime
21
 
22
  USER root
23
 
24
  # ── 2a. System deps ────────────────────────────────────────────────────────────
25
- # git : required by openclaw npm install (avoids "spawn git ENOENT")
26
- # cmake/make/python3/build-essential : openclaw native deps (canvas, sharp, etc.)
27
- # python3-venv : isolated LiteLLM install to avoid externally-managed-env errors
28
- # tini : proper pid-1 signal forwarding
29
  RUN apt-get update \
30
- && apt-get install -y --no-install-recommends \
31
  git tini ca-certificates curl \
32
  cmake make build-essential \
33
- python3 python3-venv \
 
 
34
  && rm -rf /var/lib/apt/lists/*
35
 
36
  # ── 2b. Install Node 22 (OpenClaw requires ≥22; Playwright ships Node 20) ─────
@@ -39,18 +37,21 @@ RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
39
  && rm -rf /var/lib/apt/lists/*
40
 
41
  # ── 2c. Install OpenClaw globally ─────────────────────────────────────────────
42
- # SHARP_IGNORE_GLOBAL_LIBVIPS=1 : skip system libvips check (avoids build fail)
43
- # npm_config_cache=/tmp/npm-cache : writable cache dir during build
44
  RUN SHARP_IGNORE_GLOBAL_LIBVIPS=1 \
45
  npm_config_cache=/tmp/npm-cache \
46
  npm install -g openclaw@latest \
47
  && rm -rf /tmp/npm-cache
48
 
49
  # ── 2d. Install LiteLLM into an isolated venv ─────────────────────────────────
50
- RUN python3 -m venv /opt/litellm-venv \
51
- && /opt/litellm-venv/bin/pip install --no-cache-dir "litellm[proxy]"
 
 
 
 
 
 
52
 
53
- # Make litellm available on PATH
54
  ENV PATH="/opt/litellm-venv/bin:$PATH"
55
 
56
  # ── 2e. Copy Rust sync binary + startup script ────────────────────────────────
@@ -58,7 +59,7 @@ COPY --from=builder /app/target/release/openclaw-hf-sync /usr/local/bin/openclaw
58
  COPY start.sh /app/start.sh
59
  RUN chmod +x /usr/local/bin/openclaw-hf-sync /app/start.sh
60
 
61
- # ── 2f. Create runtime user (uid 1000) and openclaw data dir ──────────────────
62
  RUN set -eux; \
63
  if ! getent passwd 1000 >/dev/null; then \
64
  groupadd -g 1000 user; \
@@ -67,10 +68,6 @@ RUN set -eux; \
67
  mkdir -p /home/user/.openclaw /home/user/app; \
68
  chown -R 1000:1000 /home/user
69
 
70
- # ── Port config ────────────────────────────────────────────────────────────────
71
- # HF Space health-check uses port 7860.
72
- # OPENCLAW_API_PORT overrides OpenClaw's default (18789).
73
- # LiteLLM proxy listens on 127.0.0.1:4000 (internal only).
74
  ENV OPENCLAW_API_PORT=7860 \
75
  OPENCLAW_WS_PORT=7861 \
76
  HOME=/home/user \
@@ -81,10 +78,5 @@ EXPOSE 7860 7861
81
  WORKDIR /home/user/app
82
  USER 1000:1000
83
 
84
- # ── Entrypoint ─────────────────────────────────────────────────────────────────
85
- # openclaw-hf-sync (pid 1 via tini):
86
- # 1. Pulls ~/.openclaw from the HF dataset
87
- # 2. Spawns start.sh → LiteLLM proxy + OpenClaw gateway
88
- # 3. Pushes workspace changes back on a timer and on shutdown
89
  ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/openclaw-hf-sync"]
90
  CMD ["/app/start.sh"]
 
11
 
12
  COPY Cargo.toml ./
13
  COPY src ./src
 
 
14
  RUN cargo build --release
15
 
16
  # ── Stage 2: Runtime ───────────────────────────────────────────────────────────
 
17
  FROM mcr.microsoft.com/playwright:v1.51.0-jammy AS runtime
18
 
19
  USER root
20
 
21
  # ── 2a. System deps ────────────────────────────────────────────────────────────
22
+ # --fix-missing: Ubuntu jammy security mirror periodically drops old python3.10
23
+ # packages causing 404 errors; this flag lets apt fall back to other sources.
24
+ # python3-venv installed separately after --fix-missing pass to ensure it lands.
 
25
  RUN apt-get update \
26
+ && apt-get install -y --no-install-recommends --fix-missing \
27
  git tini ca-certificates curl \
28
  cmake make build-essential \
29
+ python3 \
30
+ && apt-get install -y --no-install-recommends --fix-missing \
31
+ python3-venv \
32
  && rm -rf /var/lib/apt/lists/*
33
 
34
  # ── 2b. Install Node 22 (OpenClaw requires ≥22; Playwright ships Node 20) ─────
 
37
  && rm -rf /var/lib/apt/lists/*
38
 
39
  # ── 2c. Install OpenClaw globally ─────────────────────────────────────────────
 
 
40
  RUN SHARP_IGNORE_GLOBAL_LIBVIPS=1 \
41
  npm_config_cache=/tmp/npm-cache \
42
  npm install -g openclaw@latest \
43
  && rm -rf /tmp/npm-cache
44
 
45
  # ── 2d. Install LiteLLM into an isolated venv ─────────────────────────────────
46
+ # If python3-venv failed above (very old jammy), fall back to pip --user install
47
+ RUN if python3 -m venv /opt/litellm-venv 2>/dev/null; then \
48
+ /opt/litellm-venv/bin/pip install --no-cache-dir "litellm[proxy]"; \
49
+ else \
50
+ pip3 install --no-cache-dir --break-system-packages "litellm[proxy]"; \
51
+ mkdir -p /opt/litellm-venv/bin; \
52
+ ln -sf "$(which litellm)" /opt/litellm-venv/bin/litellm; \
53
+ fi
54
 
 
55
  ENV PATH="/opt/litellm-venv/bin:$PATH"
56
 
57
  # ── 2e. Copy Rust sync binary + startup script ────────────────────────────────
 
59
  COPY start.sh /app/start.sh
60
  RUN chmod +x /usr/local/bin/openclaw-hf-sync /app/start.sh
61
 
62
+ # ── 2f. Create runtime user (uid 1000) ────────────────────────────────────────
63
  RUN set -eux; \
64
  if ! getent passwd 1000 >/dev/null; then \
65
  groupadd -g 1000 user; \
 
68
  mkdir -p /home/user/.openclaw /home/user/app; \
69
  chown -R 1000:1000 /home/user
70
 
 
 
 
 
71
  ENV OPENCLAW_API_PORT=7860 \
72
  OPENCLAW_WS_PORT=7861 \
73
  HOME=/home/user \
 
78
  WORKDIR /home/user/app
79
  USER 1000:1000
80
 
 
 
 
 
 
81
  ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/openclaw-hf-sync"]
82
  CMD ["/app/start.sh"]