tcm_llm_casualAI / Dockerfile222
leonsimon23's picture
Rename Dockerfile to Dockerfile222
617f81e verified
raw
history blame contribute delete
856 Bytes
# 使用官方Python 3.10 slim镜像
FROM python:3.10-slim
# --- 1. 设置环境变量 ---
ENV PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on
# --- 2. 创建应用用户和工作目录 ---
RUN useradd --create-home --shell /bin/bash appuser
WORKDIR /app
# --- 3. [核心步骤] 复制依赖文件并安装 ---
# 将本地的requirements.txt复制到镜像中
COPY requirements.txt .
# 使用这个文件进行安装。pip会自动处理 --extra-index-url
RUN pip install -r requirements.txt
# --- 4. 复制我们最简单的测试应用 ---
COPY test_app.py .
# --- 5. 设置权限 ---
RUN chown -R appuser:appuser /app
# --- 6. 切换到非root用户 ---
USER appuser
# --- 7. 暴露端口 ---
EXPOSE 7860
# --- 8. 启动应用 ---
CMD ["gunicorn", "--workers", "1", "--bind", "0.0.0.0:7860", "test_app:app"]