FROM python:3.13-slim

WORKDIR /app

# 离线安装：wheel 预先下载到 vendor/（pip download -r requirements.txt -d vendor/）
COPY requirements.txt ./
COPY vendor/ ./vendor/
RUN pip install --no-cache-dir --no-index --find-links vendor -r requirements.txt

COPY . .

# host 网络模式下 127.0.0.1 即宿主机 MySQL
ENV DB_HOST=127.0.0.1 \
    DB_PORT=3306

EXPOSE 8000

CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port ${APP_PORT:-8000}"]
