From 18f04d5f973c5abafe05cfe84fe70e3a5568039b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=BA=E6=B5=B7=E5=9B=BD?= <404580946@qq.com> Date: Tue, 14 Apr 2026 13:56:16 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E6=B7=BB=E5=8A=A0dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..133c909 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +# 使用官方Python运行时作为基础镜像 +FROM 172.16.102.3:30648/library/python:3.13-slim + +# 设置工作目录 +WORKDIR /app + +# 设置环境变量 +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 + +# 配置uv使用阿里云源 +ENV UV_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/ +ENV UV_EXTRA_INDEX_URL=https://pypi.org/simple/ + +RUN python -m pip install --upgrade pip setuptools wheel --index-url https://mirrors.aliyun.com/pypi/simple/ + +# 安装uv +RUN pip install uv --index-url https://mirrors.aliyun.com/pypi/simple/ + +# 复制依赖文件 +COPY pyproject.toml ./ + +# 安装依赖 +RUN uv sync + +# 复制应用代码 +COPY . . + +# 创建非root用户 +RUN adduser --disabled-password --gecos '' appuser +RUN chown -R appuser:appuser /app +USER appuser + +# 暴露端口 +EXPOSE 8000 + +# 启动命令 +CMD ["uv", "run","python", "app.py"] \ No newline at end of file