Download Dockerfile-2 from airsltd/opencode: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/spaces/airsltd/opencode/resolve/main/Dockerfile-2
- Command line
-
hf download hf://spaces/airsltd/opencode/Dockerfile-2
-
curl -L -o Dockerfile-2 https://huggingface.co/spaces/airsltd/opencode/resolve/main/Dockerfile-2
1.42 kB
| # ---------- 1. 基础镜像 ---------- | |
| FROM node:20 | |
| # ---------- 2. 系统级依赖 ---------- | |
| RUN apt-get update && apt-get install -y git curl cron && rm -rf /var/lib/apt/lists/* | |
| # ---------- 3. 跳过用户创建,使用 root 用户 ---------- | |
| # 直接使用 root 用户运行所有服务 | |
| # ---------- 5. 全局安装 opencode-ai ---------- | |
| # 安装完先验证二进制是否存在,若不存在就手动解压 | |
| RUN npm install -g opencode-ai@latest && \ | |
| if [ ! -f /usr/local/lib/node_modules/opencode-ai/node_modules/opencode-linux-x64/bin/opencode ]; then \ | |
| cd /usr/local/lib/node_modules/opencode-ai && \ | |
| npm run postinstall; \ | |
| fi | |
| # ---------- 6. 工作目录 ---------- | |
| WORKDIR /app | |
| COPY package*.json ./ | |
| COPY . /app | |
| RUN if [ -f package.json ]; then npm ci --only=production; fi | |
| # ---------- 8. 启动脚本 ---------- | |
| RUN mkdir -p /usr/local/bin | |
| RUN printf '#!/bin/sh\n\ | |
| echo "Starting OpenCode AI Web Server ..."\n\ | |
| # 启动 cron 服务\n\ | |
| cron && \ | |
| echo "Cron started successfully"\n\ | |
| # 启动 opencode 服务\n\ | |
| exec /usr/local/bin/opencode serve --hostname 0.0.0.0 --port 7860\n' > /usr/local/bin/start.sh && \ | |
| chmod +x /usr/local/bin/start.sh | |
| # ---------- 9. 端口与健康检查 ---------- | |
| EXPOSE 7860 | |
| HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ | |
| CMD curl -f http://localhost:7860/health || exit 1 | |
| CMD ["/usr/local/bin/start.sh"] |