tcm_expert_builder / Dockerfile
leonsimon23's picture
Create Dockerfile
31ad386 verified
raw
history blame contribute delete
787 Bytes
# 使用官方Python 3.10 slim镜像
FROM python:3.10-slim
# --- 1. 设置工作目录 ---
WORKDIR /app
# --- 2. 创建应用用户 ---
# 最佳实践:不以root身份运行应用
RUN useradd --create-home --shell /bin/bash appuser
# --- 3. 复制测试代码和依赖文件 ---
# 只复制这两个最小化的文件
COPY test_app.py .
COPY test_requirements.txt .
# --- 4. 安装最小依赖 ---
RUN pip install --no-cache-dir -r test_requirements.txt
# --- 5. 设置权限 ---
RUN chown -R appuser:appuser /app
# --- 6. 切换到非root用户 ---
USER appuser
# --- 7. 暴露端口 ---
EXPOSE 7860
# --- 8. 启动测试应用 ---
# 明确告诉Gunicorn去运行 test_app.py 文件中的 app 实例
CMD ["gunicorn", "--workers", "1", "--bind", "0.0.0.0:7860", "test_app:app"]