Download Dockerfile from flzta/app: direct link, hf CLI and curl.
- Browser
- Download file 1.78 kB
-
https://huggingface.co/spaces/flzta/app/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/flzta/app/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/flzta/app/resolve/main/Dockerfile
1.78 kB
| FROM ubuntu:latest | |
| WORKDIR /opt/app | |
| ENV TZ Asia/Shanghai | |
| # 设置 apt 镜像源为国内镜像,加快下载速度 | |
| RUN sed -i s@/archive.ubuntu.com/@/mirrors.ustc.edu.cn/@g /etc/apt/sources.list | |
| RUN sed -i s@/security.ubuntu.com/@/mirrors.ustc.edu.cn/@g /etc/apt/sources.list | |
| # 安装必要的依赖 | |
| RUN apt-get update && apt-get install -y wget tar gzip python3 python3-pip curl bash tzdata ca-certificates --no-install-recommends | |
| RUN apt-get install -y python3.12-venv --no-install-recommends | |
| RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo Asia/Shanghai > /etc/timezone | |
| # 从构建上下文复制 app1 可执行文件 | |
| COPY app1 /opt/app/app1 | |
| COPY app.ini /opt/app/app.ini | |
| # 创建 app 数据目录 | |
| RUN mkdir -p /opt/app/app_data | |
| RUN chmod -R 755 /opt/app | |
| # 将用户 www-data 添加到已存在的组 (Ubuntu 中通常已有 www-data 用户,但为了保险起见可以尝试添加) | |
| RUN useradd -u 1000 -ms /bin/bash www-data || true | |
| # 更改 /opt/app 目录的所有权为 www-data 用户 | |
| RUN chown -R www-data:www-data /opt/app | |
| # 显式设置 app_data 目录的所有者 | |
| RUN chown -R www-data:www-data /opt/app/app_data | |
| # 在更改所有者后设置目录权限 | |
| RUN chmod -R 775 /opt/app | |
| # 创建 Python 虚拟环境并安装 webdavclient3 | |
| ENV VIRTUAL_ENV=/opt/venv | |
| RUN python3 -m venv $VIRTUAL_ENV | |
| ENV PATH="$VIRTUAL_ENV/bin:$PATH" | |
| RUN pip3 install --no-cache-dir requests webdavclient3 | |
| # 复制同步脚本 | |
| COPY sync_data.sh /opt/app/ | |
| RUN chmod +x /opt/app/sync_data.sh | |
| RUN chmod +x /opt/app/app1 | |
| # 暴露 app 的默认端口 (根据需要调整) | |
| EXPOSE 5432 | |
| # 设置运行 app 的命令,包含同步脚本 | |
| CMD ["/bin/bash", "-c", "/opt/app/sync_data.sh; sleep 10; ./app1 -c /opt/app/app.ini"] | |
| # 删除切换用户的命令 | |
| # USER www-data |