Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +22 -6
Dockerfile
CHANGED
|
@@ -1,23 +1,39 @@
|
|
|
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
|
|
|
| 3 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 4 |
PYTHONUNBUFFERED=1 \
|
| 5 |
HF_HOME=/root/.cache/huggingface \
|
| 6 |
-
TRANSFORMERS_CACHE=/root/.cache/huggingface/transformers
|
|
|
|
|
|
|
| 7 |
|
| 8 |
WORKDIR /app
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
RUN apt-get update && apt-get install -y --no-install-recommends
|
| 12 |
-
|
|
|
|
|
|
|
| 13 |
|
|
|
|
| 14 |
COPY requirements.txt .
|
| 15 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
RUN python -
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
|
|
|
| 20 |
COPY . .
|
|
|
|
| 21 |
|
| 22 |
EXPOSE 7860
|
| 23 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
# ---- Base image
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
+
# ---- Env
|
| 5 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 6 |
PYTHONUNBUFFERED=1 \
|
| 7 |
HF_HOME=/root/.cache/huggingface \
|
| 8 |
+
TRANSFORMERS_CACHE=/root/.cache/huggingface/transformers \
|
| 9 |
+
HF_HUB_ENABLE_HF_TRANSFER=1 \
|
| 10 |
+
PIP_NO_CACHE_DIR=1
|
| 11 |
|
| 12 |
WORKDIR /app
|
| 13 |
|
| 14 |
+
# ---- Minimal OS deps (no OpenGL libs needed)
|
| 15 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 16 |
+
git git-lfs \
|
| 17 |
+
&& rm -rf /var/lib/apt/lists/* \
|
| 18 |
+
&& git lfs install
|
| 19 |
|
| 20 |
+
# ---- Python deps
|
| 21 |
COPY requirements.txt .
|
| 22 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 23 |
|
| 24 |
+
# ---- Warm caches (NLTK + BLIP weights) so first request is fast
|
| 25 |
+
RUN python - <<'PY'
|
| 26 |
+
import nltk
|
| 27 |
+
nltk.download('punkt'); nltk.download('averaged_perceptron_tagger')
|
| 28 |
+
from transformers import BlipForConditionalGeneration, BlipProcessor
|
| 29 |
+
BlipProcessor.from_pretrained('Salesforce/blip-image-captioning-base')
|
| 30 |
+
BlipForConditionalGeneration.from_pretrained('Salesforce/blip-image-captioning-base')
|
| 31 |
+
print("Models ready")
|
| 32 |
+
PY
|
| 33 |
|
| 34 |
+
# ---- App code
|
| 35 |
COPY . .
|
| 36 |
+
RUN mkdir -p /app/data
|
| 37 |
|
| 38 |
EXPOSE 7860
|
| 39 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|