Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +9 -16
Dockerfile
CHANGED
|
@@ -1,40 +1,33 @@
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
| 3 |
-
# Keep caches local to the app; make NLTK writable
|
| 4 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 5 |
PYTHONUNBUFFERED=1 \
|
| 6 |
HF_HOME=/app/.cache/huggingface \
|
| 7 |
-
PIP_NO_CACHE_DIR=1
|
| 8 |
-
NLTK_DATA=/app/nltk_data
|
| 9 |
|
| 10 |
WORKDIR /app
|
| 11 |
|
| 12 |
# Minimal OS deps
|
| 13 |
-
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 14 |
-
|
| 15 |
-
&& rm -rf /var/lib/apt/lists/* \
|
| 16 |
-
&& git lfs install
|
| 17 |
|
| 18 |
# Python deps
|
| 19 |
COPY requirements.txt .
|
| 20 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 21 |
|
| 22 |
-
# Create
|
| 23 |
-
RUN mkdir -p /app/
|
| 24 |
&& python - <<'PY'
|
| 25 |
-
import os, nltk
|
| 26 |
-
print("Using NLTK_DATA:", os.environ.get("NLTK_DATA"))
|
| 27 |
-
nltk.download('punkt', download_dir=os.environ['NLTK_DATA'])
|
| 28 |
-
nltk.download('averaged_perceptron_tagger', download_dir=os.environ['NLTK_DATA'])
|
| 29 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
| 30 |
BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
|
| 31 |
BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")
|
| 32 |
-
print("
|
| 33 |
PY
|
|
|
|
|
|
|
| 34 |
|
| 35 |
# App code
|
| 36 |
COPY . .
|
| 37 |
|
| 38 |
EXPOSE 7860
|
| 39 |
-
CMD ["uvicorn",
|
| 40 |
-
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
|
|
|
| 3 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 4 |
PYTHONUNBUFFERED=1 \
|
| 5 |
HF_HOME=/app/.cache/huggingface \
|
| 6 |
+
PIP_NO_CACHE_DIR=1
|
|
|
|
| 7 |
|
| 8 |
WORKDIR /app
|
| 9 |
|
| 10 |
# Minimal OS deps
|
| 11 |
+
RUN apt-get update && apt-get install -y --no-install-recommends git git-lfs \
|
| 12 |
+
&& rm -rf /var/lib/apt/lists/* && git lfs install
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# Python deps
|
| 15 |
COPY requirements.txt .
|
| 16 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 17 |
|
| 18 |
+
# Create writable dirs, warm caches, then hand ownership to runtime user (uid 1000)
|
| 19 |
+
RUN mkdir -p /app/.cache/huggingface /app/data \
|
| 20 |
&& python - <<'PY'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
| 22 |
BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
|
| 23 |
BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")
|
| 24 |
+
print("BLIP ready")
|
| 25 |
PY
|
| 26 |
+
# HF Spaces runs the container as uid 1000; give it the whole /app tree
|
| 27 |
+
RUN chown -R 1000:1000 /app
|
| 28 |
|
| 29 |
# App code
|
| 30 |
COPY . .
|
| 31 |
|
| 32 |
EXPOSE 7860
|
| 33 |
+
CMD ["uvicorn","app:app","--host","0.0.0.0","--port","7860"]
|
|
|