# 使用Python 3.11作为基础镜像 | |
FROM python:3.11-slim | |
# 设置工作目录 | |
WORKDIR /app | |
ENV PYTHONDONTWRITEBYTECODE=1 | |
ENV PYTHONUNBUFFERED=1 | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
git \ | |
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/* | |
COPY requirements.txt . | |
RUN pip install --no-cache-dir -r requirements.txt | |
COPY . . | |
RUN adduser --disabled-password --gecos "" appuser | |
USER appuser | |
EXPOSE 7860 | |
# 启动应用 | |
CMD ["python", "main.py"] | |