Dockerfile 862 B

1234567891011121314151617181920212223242526272829303132
  1. # syntax=docker/dockerfile:1
  2. FROM registry.cn-hangzhou.aliyuncs.com/stuuudy/python:3.11-slim AS base
  3. ENV PYTHONDONTWRITEBYTECODE=1 \
  4. PYTHONUNBUFFERED=1 \
  5. PIP_DISABLE_PIP_VERSION_CHECK=1 \
  6. PIP_NO_CACHE_DIR=1
  7. WORKDIR /app
  8. # System deps
  9. # RUN apt-get update -y && apt-get install -y --no-install-recommends \
  10. # build-essential curl && \
  11. # rm -rf /var/lib/apt/lists/*
  12. # Install Python deps first (better layer caching)
  13. COPY requirements.txt .
  14. RUN pip install --no-cache-dir --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple/
  15. RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
  16. # Copy source
  17. COPY app ./app
  18. COPY README.md .
  19. # Optionally copy .env at build time (usually mounted at runtime)
  20. COPY .env .
  21. EXPOSE 8000
  22. CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]