zhv commited on
Commit
7a1702b
·
verified ·
1 Parent(s): fd33ff4

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +77 -45
Dockerfile CHANGED
@@ -1,53 +1,85 @@
1
- FROM node:22-bookworm
2
-
3
- LABEL org.opencontainers.image.source="https://github.com/phioranex/clawbot-docker"
4
- LABEL org.opencontainers.image.description="Pre-built OpenClaw (Clawbot) Docker image"
5
- LABEL org.opencontainers.image.licenses="MIT"
6
 
7
  # Install system dependencies
8
- RUN apt-get update && apt-get install -y \
9
- git \
10
- curl \
11
- ca-certificates \
12
- unzip \
13
- && rm -rf /var/lib/apt/lists/*
14
-
15
- # Install Bun (required for build)
16
- RUN curl -fsSL https://bun.sh/install | bash
17
- ENV PATH="/root/.bun/bin:${PATH}"
18
-
19
- # Enable corepack for pnpm
20
- RUN corepack enable
21
-
22
- WORKDIR /app
23
-
24
- # Clone and build OpenClaw
25
- ARG OPENCLAW_VERSION=main
26
- RUN git clone --depth 1 --branch ${OPENCLAW_VERSION} https://github.com/openclaw/openclaw.git .
27
-
28
- # Install dependencies
29
- RUN pnpm install --frozen-lockfile
30
-
31
- # Build
32
- RUN OPENCLAW_A2UI_SKIP_MISSING=1 pnpm build
33
- # Force pnpm for UI build (Bun may fail on ARM/Synology architectures)
34
- RUN npm_config_script_shell=bash pnpm ui:install
35
- RUN npm_config_script_shell=bash pnpm ui:build
36
 
37
- # Clean up build artifacts to reduce image size
38
- RUN rm -rf .git node_modules/.cache
39
 
40
- # Create app user (node already exists in base image)
41
- RUN mkdir -p /home/node/.openclaw /home/node/.openclaw/workspace \
42
- && chown -R node:node /home/node /app
43
 
44
- USER node
 
 
 
45
 
46
- WORKDIR /home/node
 
47
 
48
- ENV NODE_ENV=production
49
- ENV PATH="/app/node_modules/.bin:${PATH}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
- # Default command
52
- ENTRYPOINT ["node", "/app/dist/index.js"]
53
- CMD ["--help"]
 
1
+ FROM node:22-slim
 
 
 
 
2
 
3
  # Install system dependencies
4
+ RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
+ # Install OpenClaw globally
7
+ RUN npm install -g openclaw@latest
8
 
9
+ # Create config directory
10
+ RUN mkdir -p /root/.openclaw
 
11
 
12
+ # Set up environment for Hugging Face Spaces
13
+ ENV PORT=18789
14
+ ENV OPENCLAW_GATEWAY_MODE=local
15
+ ENV OPENCLAW_GATEWAY_PASSWORD=${OPENCLAW_GATEWAY_PASSWORD}
16
 
17
+ # Expose the port (Hugging Face default)
18
+ EXPOSE 18789
19
 
20
+ # Create a startup script that generates config and starts OpenClaw
21
+ RUN echo '#!/bin/bash\n\
22
+ set -x\n\
23
+ \n\
24
+ # Check for required environment variables\n\
25
+ if [ -z "$GEMINI_APIKEY" ]; then\n\
26
+ echo "ERROR: GEMINI_APIKEY is not set. Agent will fail. Exiting."\n\
27
+ exit 1\n\
28
+ fi\n\
29
+ \n\
30
+ # Create critical missing directories\n\
31
+ mkdir -p /root/.openclaw/agents/main/agent\n\
32
+ mkdir -p /root/.openclaw/agents/main/sessions\n\
33
+ mkdir -p /root/.openclaw/credentials\n\
34
+ \n\
35
+ # Remove auth-profiles.json if it exists to force env var usage\n\
36
+ rm -f /root/.openclaw/agents/main/agent/auth-profiles.json\n\
37
+ \n\
38
+ # Generate minimal config if not exists\n\
39
+ if [ ! -f /root/.openclaw/openclaw.json ]; then\n\
40
+ cat > /root/.openclaw/openclaw.json << EOF\n\
41
+ {\n\
42
+ "env": {\n\
43
+ "GOOGLE_API_KEY": "${GEMINI_APIKEY}",\n\
44
+ "GEMINI_API_KEY": "${GEMINI_APIKEY}",\n\
45
+ "GOOGLE_GENERATIVE_AI_API_KEY": "${GEMINI_APIKEY}",\n\
46
+ "PALM_API_KEY": "${GEMINI_APIKEY}"\n\
47
+ },\n\
48
+ "gateway": {\n\
49
+ "mode": "local",\n\
50
+ "bind": "lan",\n\
51
+ "port": 18789,\n\
52
+ "trustedProxies": ["0.0.0.0/0"],\n\
53
+ "auth": {\n\
54
+ "mode": "token",\n\
55
+ "token": "${OPENCLAW_GATEWAY_PASSWORD}"\n\
56
+ },\n\
57
+ "controlUi": {\n\
58
+ "allowInsecureAuth": true\n\
59
+ }\n\
60
+ },\n\
61
+ "agents": {\n\
62
+ "defaults": {\n\
63
+ "model": {\n\
64
+ "primary": "google/gemini-1.5-pro"\n\
65
+ }\n\
66
+ }\n\
67
+ }\n\
68
+ }\n\
69
+ EOF\n\
70
+ fi\n\
71
+ \n\
72
+ # Fix permissions\n\
73
+ chmod 700 /root/.openclaw\n\
74
+ chmod 600 /root/.openclaw/openclaw.json\n\
75
+ chmod 600 /root/.openclaw/agents/main/agent/auth-profiles.json\n\
76
+ \n\
77
+ # Fix config if needed\n\
78
+ openclaw doctor --fix\n\
79
+ \n\
80
+ # Start OpenClaw gateway\n\
81
+ echo "Starting OpenClaw gateway on port 18789..."\n\
82
+ exec openclaw gateway run --port 18789\n\
83
+ ' > /usr/local/bin/start-openclaw && chmod +x /usr/local/bin/start-openclaw
84
 
85
+ CMD ["/usr/local/bin/start-openclaw"]