| FROM openresty/openresty:latest | |
| # 安装 Node.js (用于 OpenCode) | |
| RUN apt-get update && apt-get install -y curl cron && \ | |
| curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ | |
| apt-get install -y nodejs && \ | |
| npm install -g opencode-ai | |
| # 复制自定义配置文件 | |
| COPY nginx/nginx.conf /usr/local/openresty/nginx/conf/nginx.conf | |
| COPY nginx/conf.d/default.conf /usr/local/openresty/nginx/conf/conf.d/default.conf | |
| # 不再复制静态 .htpasswd 文件,将在启动时动态生成 | |
| # 复制静态文件 | |
| COPY nginx/html/ /usr/local/openresty/nginx/html/ | |
| # 复制 OpenCode 配置文件 | |
| COPY opencode.json /app/opencode.json | |
| COPY AGENT.md /etc/AGENT.md | |
| # 复制 Cron 配置文件和脚本 | |
| COPY crontab /etc/cron.d/ocngx-cron | |
| COPY cron-jobs/ /etc/cron-jobs/ | |
| # 设置 Cron 配置权限 | |
| RUN chmod 0644 /etc/cron.d/ocngx-cron && \ | |
| crontab /etc/cron.d/ocngx-cron && \ | |
| chmod +x /etc/cron-jobs/*.sh | |
| # 创建 OpenCode 启动脚本 | |
| COPY docker-start.sh /docker-start.sh | |
| RUN chmod +x /docker-start.sh | |
| # 暴露端口(Hugging Face Spaces 通常使用 7860) | |
| EXPOSE 7860 | |
| # 启动脚本(同时启动 OpenResty 和 OpenCode) | |
| CMD ["/docker-start.sh"] |