create dockerfile
Browse filesadd dockerfile for details
- Dockerfile +85 -0
Dockerfile
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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"]
|