Image_Tagger / Dockerfile
stephenebert's picture
Update Dockerfile
f33deaf verified
raw
history blame contribute delete
992 Bytes
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
HF_HOME=/app/.cache/huggingface \
PIP_NO_CACHE_DIR=1
WORKDIR /app
# Minimal OS deps
RUN apt-get update && apt-get install -y --no-install-recommends git git-lfs \
&& rm -rf /var/lib/apt/lists/* && git lfs install
# Python deps
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Create writable dirs, warm caches, then hand ownership to runtime user (uid 1000)
RUN mkdir -p /app/.cache/huggingface /app/data \
&& python - <<'PY'
from transformers import BlipProcessor, BlipForConditionalGeneration
BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")
print("BLIP ready")
PY
# HF Spaces runs the container as uid 1000; give it the whole /app tree
RUN chown -R 1000:1000 /app
# App code
COPY . .
EXPOSE 7860
CMD ["uvicorn","app:app","--host","0.0.0.0","--port","7860"]