| FROM python:3.11-slim | |
| ENV PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| TZ=Asia/Shanghai \ | |
| PORT=7860 | |
| WORKDIR /app | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| COPY . . | |
| RUN rm -rf __pycache__ core/__pycache__ routes/__pycache__ \ | |
| && find . -name "*.pyc" -delete \ | |
| && chmod +x docker-entrypoint.sh | |
| EXPOSE 7860 | |
| HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ | |
| CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/v1/models')" || exit 1 | |
| ENTRYPOINT ["./docker-entrypoint.sh"] | |