| # Dockerfile -- HF Space deployment (optimized) | |
| FROM node:22-slim | |
| # 1. System deps (minimal) | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| python3 python3-pip python3-requests ca-certificates curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # 2. Install OpenClaw at build time (cached) | |
| RUN npm install -g openclaw@latest --unsafe-perm --no-audit --no-fund | |
| # 3. Install Caddy (reverse proxy) | |
| RUN curl -fsSL https://caddy.org/install | bash | |
| # ~/.openclaw/bin 已经在 PATH 中 | |
| # 3. Copy app files | |
| WORKDIR /app | |
| COPY backup-manager.py . | |
| COPY config-generator.py . | |
| COPY start-openclaw.sh . | |
| COPY scripts/ ./scripts/ | |
| COPY Caddyfile . | |
| RUN chmod +x start-openclaw.sh scripts/*.sh | |
| # 4. Environment | |
| ENV PORT=7860 \ | |
| OPENCLAW_GATEWAY_PORT=18889 \ | |
| OPENCLAW_STATE_DIR=/root/.openclaw \ | |
| HOME=/root \ | |
| NODE_OPTIONS=--max-old-space-size=512 \ | |
| NPM_CONFIG_REGISTRY=https://registry.npmmirror.com \ | |
| NODE_ENV=production \ | |
| ALLOW_HTTP_BASIC_OVER_HTTP=1 | |
| EXPOSE 7860 | |
| CMD ["./start-openclaw.sh"] | |