Spaces:
Paused
Paused
Download Dockerfile1 from onlyrickroll/opcl: direct link, hf CLI and curl.
- Browser
- Download file 1.48 kB
-
https://huggingface.co/spaces/onlyrickroll/opcl/resolve/main/Dockerfile1
- Command line
-
hf download hf://spaces/onlyrickroll/opcl/Dockerfile1
-
curl -L -o Dockerfile1 https://huggingface.co/spaces/onlyrickroll/opcl/resolve/main/Dockerfile1
1.48 kB
| # 使用轻量级的 Alpine 镜像 | |
| FROM alpine:latest | |
| # 安装必要的软件包 | |
| # openssh: SSH 服务 | |
| # nginx: Web 服务 | |
| # sudo: 允许 user 用户执行必要命令 | |
| # bash: 方便编写启动脚本 | |
| RUN apk add --no-cache \ | |
| openssh \ | |
| nginx \ | |
| sudo \ | |
| bash \ | |
| curl | |
| # --- 权限与目录配置 --- | |
| # 创建 Hugging Face 指定的 UID 1000 用户 | |
| RUN adduser -D -u 1000 user && \ | |
| echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | |
| # 创建 SSH 所需的 host keys 和 运行目录 | |
| RUN ssh-keygen -A && \ | |
| mkdir -p /run/sshd /var/lib/nginx/tmp /var/log/nginx && \ | |
| chown -R user:user /run/sshd /var/lib/nginx /var/log/nginx /etc/ssh /etc/nginx | |
| # --- 服务配置 --- | |
| # 修改 Nginx 监听 7860 端口(HF 强制要求) | |
| RUN sed -i 's/listen 80;/listen 7860;/' /etc/nginx/http.d/default.conf | |
| # 修改 SSH 配置 (允许用户登录,监听高位端口) | |
| RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \ | |
| sed -i 's/#PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config | |
| # 设置用户密码 | |
| RUN echo 'user:huggingface' | chpasswd | |
| # 设置工作目录 | |
| WORKDIR /home/user | |
| # 创建启动脚本 | |
| RUN echo '#!/bin/bash\n\ | |
| # 启动 SSH 服务 (必须以 root 权限或 sudo 启动)\n\ | |
| # sudo /usr/sbin/sshd\n\ | |
| # 启动 Nginx (前台运行)\n\ | |
| nginx -g "daemon off;"' > entrypoint.sh && chmod +x entrypoint.sh | |
| # 切换到非 root 用户 | |
| USER user | |
| EXPOSE 7860 | |
| CMD ["/bin/bash", "entrypoint.sh"] |