fashion-api / Dockerfile
BigBawdi's picture
Update Dockerfile
15030f4 verified
Raw
History Blame Contribute Delete
1.31 kB
FROM python:3.9-slim
# 1. Install system libraries required by OpenCV / Ultralytics
RUN apt-get update && apt-get install -y --no-install-recommends \
libglib2.0-0 \
libgl1 \
libxcb1 \
libx11-6 \
libxext6 \
libsm6 \
libxrender1 \
&& rm -rf /var/lib/apt/lists/*
# 2. Set working directory
WORKDIR /app
# 3. Copy requirements
COPY requirements.txt .
# 4. Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# 5. Download Fashion-CLIP during build
RUN python -c "from transformers import CLIPModel, CLIPProcessor; \
CLIPModel.from_pretrained('patrickjohncyh/fashion-clip'); \
CLIPProcessor.from_pretrained('patrickjohncyh/fashion-clip'); \
print('Fashion-CLIP model preloaded!')"
# 6. Download YOLO model during build
RUN python -c "from ultralytics import YOLO; \
YOLO('yolov8n.pt'); \
print('YOLO model preloaded!')"
# 7. Copy application code
COPY . .
# 8. Create non-root user
RUN useradd -m -u 1000 user
# 9. Give the application user access to the application directory
RUN chown -R user:user /app
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PYTHONUNBUFFERED=1 \
YOLO_CONFIG_DIR=/tmp/Ultralytics
# 10. Start application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]