Spaces:
Paused
Paused
Download Dockerfile from onlyrickroll/opcl: direct link, hf CLI and curl.
- Browser
- Download file 2.41 kB
-
https://huggingface.co/spaces/onlyrickroll/opcl/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/onlyrickroll/opcl/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/onlyrickroll/opcl/resolve/main/Dockerfile
2.41 kB
| FROM node:slim | |
| # 安装依赖:SSH、Nginx、Cloudflared、bash | |
| RUN apt install --no-cache openssh bash curl nginx && \ | |
| # 设置 root 密码 | |
| echo "root:123456" | chpasswd && \ | |
| sed -i 's/#Port 22/Port 2222/' /etc/ssh/sshd_config && \ | |
| sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \ | |
| sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \ | |
| # 核心修改:关闭严格模式 | |
| echo "StrictModes no" >> /etc/ssh/sshd_config && \ | |
| # 创建必要目录 | |
| mkdir -p /var/run/sshd /run/nginx /etc/cloudflared && \ | |
| # 生成 SSH host keys | |
| ssh-keygen -A && \ | |
| rm -rf /var/cache/apt/* | |
| #touch /etc/nginx/nginx.conf | |
| # 复制 Nginx 配置 | |
| #COPY nginx.conf /etc/nginx/nginx.conf | |
| # 5. 覆盖默认配置,监听 7860 端口 | |
| # 注意:非 root 用户无法监听 1024 以下的端口(如 80),但可以监听 7860 | |
| RUN echo 'server { \ | |
| listen 7860; \ | |
| server_name localhost; \ | |
| location / { \ | |
| root /usr/share/nginx/html; \ | |
| index index.html index.htm; \ | |
| try_files $uri $uri/ /index.html; \ | |
| } \ | |
| }' > /etc/nginx/conf.d/default.conf | |
| # 复制 Cloudflared 配置 | |
| # 2. 安装 Cloudflare Tunnel | |
| RUN curl -L --output /usr/local/bin/cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && \ | |
| chmod +x /usr/local/bin/cloudflared | |
| #COPY config.yml /etc/cloudflared/config.yml | |
| # 启动脚本 | |
| #COPY start.sh /start.sh | |
| #RUN chmod +x /start.sh | |
| RUN npm install -g openclaw@latest | |
| # 暴露端口(容器内) | |
| RUN useradd -D -u 1000 user && \ | |
| echo "user:hf123" | chpasswd | |
| # 4. 目录授权 (关键步骤) | |
| RUN mkdir -p /var/run/sshd /app/.cloudflared && \ | |
| chown -R user:user /usr/share/nginx/html /var/cache/nginx /var/log/nginx /etc/nginx /var/run/sshd /etc/ssh /var/run /app && \ | |
| touch /var/run/nginx.pid && \ | |
| chown user:user /var/run/nginx.pid | |
| RUN chmod 4755 /bin/busybox && chmod 644 /etc/shadow | |
| # 暴露 7860 (Web) 和 2222 (SSH) | |
| EXPOSE 7860 2222 | |
| # 3. 切换到非 root 用户 | |
| USER user | |
| WORKDIR /app | |
| # 复制并设置 entrypoint 脚本 | |
| COPY --chown=user entrypoint.sh /app/entrypoint.sh | |
| RUN chmod +x /app/entrypoint.sh | |
| #CMD sh -c "#/usr/sbin/sshd && \ nginx -g 'daemon off;'" | |
| #CMD /usr/sbin/sshd && nginx -g "daemon off;" | |
| #CMD ["nginx", "-g", "daemon off;"] | |
| CMD ["/app/entrypoint.sh"] |