Dockerfile 1000 B

12345678910111213141516171819202122232425262728293031
  1. FROM python:3.10-slim
  2. WORKDIR /app
  3. ENV PYTHONDONTWRITEBYTECODE 1
  4. ENV PYTHONUNBUFFERED 1
  5. # Global setting to suppress "Running as root" warning for all pip commands
  6. ENV PIP_ROOT_USER_ACTION=ignore
  7. # Prevent debconf errors during build
  8. ARG DEBIAN_FRONTEND=noninteractive
  9. # Update apt source to TUNA (Optional, speeds up system package install) and install dependencies
  10. RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list.d/debian.sources || true \
  11. && apt-get update && apt-get install -y --no-install-recommends \
  12. gcc \
  13. default-libmysqlclient-dev \
  14. pkg-config \
  15. tzdata \
  16. && rm -rf /var/lib/apt/lists/*
  17. COPY requirements.txt .
  18. # Use Tsinghua PyPI Mirror & Upgrade pip
  19. RUN pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple \
  20. && pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
  21. COPY . .
  22. # Run application
  23. CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]