FROM python:3.11-slim WORKDIR /app # 安装系统依赖(gzip 用于压缩 JSON 响应) RUN apt-get update && apt-get install -y --no-install-recommends \ gzip \ && rm -rf /var/lib/apt/lists/* COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY app.py . COPY static/ static/ COPY data/ data/ # 可选:预压缩 search_data.json 加速首次加载 RUN if [ -f data/search_data.json ]; then \ gzip -k -9 data/search_data.json; \ fi EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "info"]