cwbdayi commited on
Commit
2ddcefc
·
verified ·
1 Parent(s): 510ae5a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -45
Dockerfile CHANGED
@@ -6,82 +6,56 @@ RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
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=7860
14
  ENV OPENCLAW_GATEWAY_MODE=local
15
- ENV OPENCLAW_GATEWAY_PASSWORD=${SETUP_PASSWORD}
16
 
17
- # Expose the port (Hugging Face default)
18
- EXPOSE 7860
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_API_KEY_1" ]; then\n\
26
- echo "ERROR: GEMINI_API_KEY_1 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_API_KEY_1}",\n\
44
  "GEMINI_API_KEY": "${GEMINI_API_KEY_1}",\n\
45
- #"GOOGLE_GENERATIVE_AI_API_KEY": "${GEMINI_API_KEY_1}",\n\
46
  "PALM_API_KEY": "${GEMINI_API_KEY_1}"\n\
47
  },\n\
48
  "gateway": {\n\
49
  "mode": "local",\n\
50
- "bind": "lan",\n\
51
  "port": 7860,\n\
52
- "trustedProxies": ["0.0.0.0/0"],\n\
53
  "auth": {\n\
54
  "mode": "token",\n\
55
  "token": "${SETUP_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-3-flash"\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
- # Set Key\n\
78
- openclaw onboard --auth-choice gemini-api-key\n\
79
- # Fix config if needed\n\
80
- openclaw doctor --fix\n\
81
  \n\
82
  # Start OpenClaw gateway\n\
83
- echo "Starting OpenClaw gateway on port 7860..."\n\
84
  exec openclaw gateway run --port 7860\n\
85
- ' > /usr/local/bin/start-openclaw && chmod +x /usr/local/bin/start-openclaw
86
 
87
- CMD ["/usr/local/bin/start-openclaw"]
 
6
  # Install OpenClaw globally
7
  RUN npm install -g openclaw@latest
8
 
9
+ # Create a non-root user for Hugging Face compatibility
10
+ RUN useradd -m -u 1000 user
11
+ USER user
12
+ ENV HOME=/home/user
13
+ ENV PATH=$HOME/.local/bin:$PATH
14
 
15
  # Set up environment for Hugging Face Spaces
16
  ENV PORT=7860
17
  ENV OPENCLAW_GATEWAY_MODE=local
 
18
 
19
+ WORKDIR $HOME/app
 
20
 
21
+ # Create a startup script
22
  RUN echo '#!/bin/bash\n\
23
+ set -e\n\
24
  \n\
25
+ # Setup directory structure in user home\n\
26
+ mkdir -p $HOME/.openclaw/agents/main/agent\n\
27
+ mkdir -p $HOME/.openclaw/agents/main/sessions\n\
28
+ mkdir -p $HOME/.openclaw/credentials\n\
 
29
  \n\
30
+ # Generate config\n\
31
+ cat > $HOME/.openclaw/openclaw.json << EOF\n\
 
 
 
 
 
 
 
 
 
32
  {\n\
33
  "env": {\n\
 
34
  "GEMINI_API_KEY": "${GEMINI_API_KEY_1}",\n\
 
35
  "PALM_API_KEY": "${GEMINI_API_KEY_1}"\n\
36
  },\n\
37
  "gateway": {\n\
38
  "mode": "local",\n\
39
+ "bind": "0.0.0.0",\n\
40
  "port": 7860,\n\
 
41
  "auth": {\n\
42
  "mode": "token",\n\
43
  "token": "${SETUP_PASSWORD}"\n\
 
 
 
44
  }\n\
45
  },\n\
46
  "agents": {\n\
47
  "defaults": {\n\
48
  "model": {\n\
49
+ "primary": "google/gemini-3-flash-preview"\n\
50
  }\n\
51
  }\n\
52
  }\n\
53
  }\n\
54
  EOF\n\
 
 
 
 
 
 
 
 
 
 
 
55
  \n\
56
  # Start OpenClaw gateway\n\
57
+ echo "Starting OpenClaw on port 7860..."\n\
58
  exec openclaw gateway run --port 7860\n\
59
+ ' > $HOME/app/start.sh && chmod +x $HOME/app/start.sh
60
 
61
+ CMD ["/home/user/app/start.sh"]