forked from coollabsio/openclaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.base
More file actions
97 lines (78 loc) · 3.59 KB
/
Dockerfile.base
File metadata and controls
97 lines (78 loc) · 3.59 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Build openclaw from source (some dist files are not shipped via npm).
FROM node:22-bookworm AS openclaw-build
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
git \
ca-certificates \
curl \
python3 \
make \
g++ \
&& rm -rf /var/lib/apt/lists/*
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH="/root/.bun/bin:${PATH}"
RUN corepack enable
WORKDIR /openclaw
ARG OPENCLAW_GIT_REF=main
RUN git clone --depth 1 --branch "${OPENCLAW_GIT_REF}" https://github.com/openclaw/openclaw.git .
# Patch: relax version requirements for packages using workspace protocol.
RUN set -eux; \
find ./extensions -name 'package.json' -type f | while read -r f; do \
sed -i -E 's/"openclaw"[[:space:]]*:[[:space:]]*">=[^"]+"/"openclaw": "*"/g' "$f"; \
sed -i -E 's/"openclaw"[[:space:]]*:[[:space:]]*"workspace:[^"]+"/"openclaw": "*"/g' "$f"; \
done
RUN pnpm install --no-frozen-lockfile
RUN pnpm build
ENV OPENCLAW_PREFER_PNPM=1
RUN pnpm ui:install && pnpm ui:build
# Runtime image
FROM node:22-bookworm
ENV NODE_ENV=production
ENV NODE_COMPILE_CACHE=/var/tmp/openclaw-compile-cache
ENV OPENCLAW_NO_RESPAWN=1
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
build-essential \
file \
procps \
&& rm -rf /var/lib/apt/lists/*
# Install Linuxbrew (installer refuses to run as root, so use a temp user)
RUN useradd -m -s /bin/bash linuxbrew \
&& mkdir -p /home/linuxbrew/.linuxbrew \
&& chown -R linuxbrew:linuxbrew /home/linuxbrew
USER linuxbrew
RUN NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
USER root
RUN chmod -R a+rx /home/linuxbrew/.linuxbrew
ENV HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew" \
HOMEBREW_CELLAR="/home/linuxbrew/.linuxbrew/Cellar" \
HOMEBREW_REPOSITORY="/home/linuxbrew/.linuxbrew/Homebrew" \
PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:${PATH}"
# Install Go (used by many skills)
RUN curl -fsSL https://go.dev/dl/go1.24.1.linux-$(dpkg --print-architecture).tar.gz | tar -C /usr/local -xz
ENV PATH="/usr/local/go/bin:${PATH}"
# Install uv (fast Python package manager, used by Python-based skills)
RUN curl -fsSL https://astral.sh/uv/install.sh | sh
ENV PATH="/root/.local/bin:${PATH}"
# Ensure tool paths survive login-shell PATH reset (/etc/profile overwrites PATH)
RUN printf '%s\n' \
'export PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/usr/local/go/bin:/root/.local/bin:$PATH"' \
> /etc/profile.d/custom-tools.sh \
&& chmod +x /etc/profile.d/custom-tools.sh
# Install under /opt/openclaw/app so that ../../ from dist/ lands at /opt/openclaw
# which is where we place the symlinks. This avoids polluting / with project files.
COPY --from=openclaw-build /openclaw /opt/openclaw/app
RUN printf '%s\n' '#!/usr/bin/env bash' 'exec node /opt/openclaw/app/openclaw.mjs "$@"' > /usr/local/bin/openclaw \
&& chmod +x /usr/local/bin/openclaw
# Pre-create Node.js compile cache directory so repeated CLI runs are faster.
# NODE_COMPILE_CACHE (Node 22+) persists V8 bytecode across restarts.
RUN mkdir -p /var/tmp/openclaw-compile-cache
# Compiled JS in dist/ resolves ../../ relative to import.meta.url.
# Files in /opt/openclaw/app/dist/ resolve ../../ to /opt/openclaw/.
# Symlink docs/assets/package.json there so the paths work.
RUN ln -s /opt/openclaw/app/docs /opt/openclaw/docs \
&& ln -s /opt/openclaw/app/assets /opt/openclaw/assets \
&& ln -s /opt/openclaw/app/package.json /opt/openclaw/package.json