python / Dockerfile
FlashCode-Lab's picture
Create Dockerfile
f40dfdf verified
raw
history blame contribute delete
856 Bytes
# 使用 Ubuntu 作为基础镜像,这比直接用 Python 镜像更像一台完整的电脑
FROM ubuntu:22.04
# 设置环境变量,防止安装过程中的交互弹窗
ENV DEBIAN_FRONTEND=noninteractive
# 安装 Python, pip, curl 和基础工具
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
curl \
git \
sudo \
&& rm -rf /var/lib/apt/lists/*
# 安装网页版 VS Code (code-server)
RUN curl -fsSL https://code-server.dev/install.sh | sh
# 创建一个非 root 用户(Hugging Face 安全要求)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
# 暴露 Hugging Face 必须的 7860 端口
EXPOSE 7860
# 启动 code-server:不设密码,监听 7860 端口
CMD ["code-server", "--auth", "none", "--bind-addr", "0.0.0.0:7860", "."]