Dockerfile 457 B

123456789101112131415161718
  1. FROM python:3.13-slim
  2. WORKDIR /app
  3. # 离线安装:wheel 预先下载到 vendor/(pip download -r requirements.txt -d vendor/)
  4. COPY requirements.txt ./
  5. COPY vendor/ ./vendor/
  6. RUN pip install --no-cache-dir --no-index --find-links vendor -r requirements.txt
  7. COPY . .
  8. # host 网络模式下 127.0.0.1 即宿主机 MySQL
  9. ENV DB_HOST=127.0.0.1 \
  10. DB_PORT=3306
  11. EXPOSE 8000
  12. CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port ${APP_PORT:-8000}"]