Download Dockerfile from erdes/test1: direct link, hf CLI and curl.
- Browser
- Download file 2.29 kB
-
https://huggingface.co/spaces/erdes/test1/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/erdes/test1/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/erdes/test1/resolve/main/Dockerfile
2.29 kB
| FROM ubuntu:22.04 | |
| # 避免交互式配置 | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # 安装基础包 | |
| RUN apt-get update && apt-get install -y \ | |
| curl \ | |
| wget \ | |
| git \ | |
| nginx \ | |
| python3 \ | |
| python3-pip \ | |
| nodejs \ | |
| npm \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # 安装code-server | |
| RUN curl -fsSL https://code-server.dev/install.sh | sh | |
| # 安装cloudflared | |
| RUN wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb \ | |
| && dpkg -i cloudflared-linux-amd64.deb \ | |
| && rm cloudflared-linux-amd64.deb | |
| # 创建用户 (HF Spaces要求) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| WORKDIR /home/user | |
| # 配置code-server | |
| RUN mkdir -p /home/user/.config/code-server/ \ | |
| && echo -e "bind-addr: 0.0.0.0:7860\nauth: password\ncert: false" > /home/user/.config/code-server/config.yaml | |
| # 切换回root配置nginx | |
| USER root | |
| # 创建nginx配置 | |
| RUN mkdir -p /var/www/html | |
| RUN echo '<html><head><title>VSCode Server</title></head><body><h1>Welcome</h1><p>VSCode Server is running!</p></body></html>' > /var/www/html/index.html | |
| RUN echo 'pid /home/user/nginx.pid;\ | |
| error_log /home/user/nginx_error.log;\ | |
| \ | |
| events {\ | |
| worker_connections 1024;\ | |
| }\ | |
| \ | |
| http {\ | |
| include /etc/nginx/mime.types;\ | |
| default_type application/octet-stream;\ | |
| \ | |
| access_log /home/user/nginx_access.log;\ | |
| \ | |
| server {\ | |
| listen 8080;\ | |
| server_name _;\ | |
| root /var/www/html;\ | |
| index index.html;\ | |
| \ | |
| location / {\ | |
| try_files $uri $uri/ =404;\ | |
| }\ | |
| \ | |
| location /admin-vscode {\ | |
| proxy_pass http://127.0.0.1:7860;\ | |
| proxy_set_header Host $host;\ | |
| proxy_set_header X-Real-IP $remote_addr;\ | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\ | |
| proxy_set_header X-Forwarded-Proto $scheme;\ | |
| }\ | |
| }\ | |
| }' > /etc/nginx/nginx.conf | |
| # 设置权限 | |
| RUN chown -R user:user /var/www/html /home/user | |
| RUN chmod -R 755 /var/www/html | |
| # 复制启动脚本 | |
| COPY start-services-minimal.sh /usr/bin/start-services.sh | |
| RUN chmod +x /usr/bin/start-services.sh | |
| # 切换回用户 | |
| USER user | |
| # 设置环境变量 | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| EXPOSE 7860 | |
| EXPOSE 8080 | |
| CMD ["/usr/bin/start-services.sh"] |