Spaces:
Sleeping
Sleeping
# Use Python 3.9 slim base image | |
FROM python:3.9-slim | |
# Install system dependencies | |
RUN apt-get update && apt-get install -y \ | |
libgl1-mesa-glx \ | |
libglib2.0-0 \ | |
wget \ | |
git \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Set working directory | |
WORKDIR /app | |
# Copy requirements and install dependencies | |
COPY requirements.txt . | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Create directories for models and temporary files with proper permissions | |
RUN mkdir -p /app/weights/icon_detect /app/weights/icon_caption_florence /app/imgs \ | |
&& chown -R 1000:1000 /app | |
# Copy application code | |
COPY main.py utils.py download_models.py ./ | |
# Download models during build | |
RUN python download_models.py | |
# Set up user for HF Spaces | |
RUN useradd -m -u 1000 user | |
USER user | |
ENV PATH="/home/user/.local/bin:$PATH" | |
# Run the application | |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] |