|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FROM python:3.11-slim as builder |
|
|
|
|
|
WORKDIR /app |
|
|
|
|
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \ |
|
|
build-essential \ |
|
|
git \ |
|
|
&& rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
|
|
|
COPY pyproject.toml README.md ./ |
|
|
|
|
|
|
|
|
RUN pip install --no-cache-dir --upgrade pip && \ |
|
|
pip install --no-cache-dir . |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FROM python:3.11-slim |
|
|
|
|
|
WORKDIR /app |
|
|
|
|
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \ |
|
|
libgomp1 \ |
|
|
&& rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
|
|
|
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages |
|
|
COPY --from=builder /usr/local/bin /usr/local/bin |
|
|
|
|
|
|
|
|
COPY app ./app |
|
|
|
|
|
|
|
|
|
|
|
RUN python -c "from open_clip import create_model_and_transforms; \ |
|
|
model, _, preprocess = create_model_and_transforms('ViT-B-16-SigLIP', pretrained='webli'); \ |
|
|
print('✅ SigLIP model cached')" |
|
|
|
|
|
|
|
|
RUN mkdir -p /root/.cache/huggingface |
|
|
|
|
|
|
|
|
ENV PYTHONUNBUFFERED=1 |
|
|
ENV PYTHONDONTWRITEBYTECODE=1 |
|
|
|
|
|
|
|
|
EXPOSE 7860 |
|
|
|
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ |
|
|
CMD python -c "import httpx; httpx.get('http://localhost:7860/health')" || exit 1 |
|
|
|
|
|
|
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"] |
|
|
|