Update Dockerfile
Browse files1234567891011121314151617181920212223242526272829303132# 使用 Python 3.10 稳定版镜像FROM python:3.10-slim# 安装系统必要组件# 修复点:将 libgl1-mesa-glx 替换为 libgl1RUN apt-get update && apt-get install -y \curl \wget \git \libgl1 \libglib2.0-0 \&& rm -rf /var/lib/apt/lists/*# 安装 code-server (网页版 VS Code)RUN curl -fsSL https://code-server.dev/install.sh | sh# 创建并切换到非 root 用户 (Hugging Face 安全规范)RUN useradd -m -u 1000 userUSER userENV HOME=/home/user \PATH=/home/user/.local/bin:$PATHWORKDIR $HOME/app# 确保 requirements.txt 存在(如果你还没创建,可以先注释掉下面这两行)# 或者直接在这里安装库RUN pip install --no-cache-dir numpy matplotlib# 暴露端口EXPOSE 7860# 启动命令:禁用密码验证CMD ["code-server", "--bind-addr", "0.0.0.0:7860", "--auth", "none", "."]1234567891011121314151617181920212223242526272829303132FROM python:3.10-slim# 1. 安装基础工具和字体管理工具RUN apt-get update && apt-get install -y \curl \wget \fontconfig \libgl1 \libglib2.0-0 \&& rm -rf /var/lib/apt/lists/*# 2. 下载并安装“霞鹜文楷” (LXGW WenKai)# 我们直接从 GitHub 下载编译好的字体文件RUN mkdir -p /usr/share/fonts/truetype/lxgw && \wget https://github.com/lxgw/LxgwWenKai/releases/download/v1.330/LXGWWenKai-Regular.ttf -O /usr/share/fonts/truetype/lxgw/LXGWWenKai-Regular.ttf && \fc-cache -fv# 3. 安装数学库和 JupyterRUN pip install --no-cache-dir numpy matplotlib jupyter# 4. 创建非 root 用户RUN useradd -m -u 1000 userUSER userWORKDIR /home/user/app# 5. 预先生成 Matplotlib 配置(防止中文显示为方块)# 这里通过环境变量告诉脚本在运行前清理缓存ENV MPLCONFIGDIR=/home/user/app/.matplotlib-cache# 6. 启动 Jupyter Notebook# 禁用 Token 方便你直接访问,设置在 7860 端口CMD ["jupyter", "notebook", "--ip=0.0.0.0", "--port=7860", "--no-browser", "--allow-root", "--NotebookApp.token=''", "--NotebookApp.password=''"]
Dockerfile+18-18