File size: 1,106 Bytes
336b59e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Use official Python image with a slim footprint
FROM python:3.10-slim

# Set the working directory inside the container
WORKDIR /app

# Install system dependencies (required for some Python ML packages and OpenCV if needed later)
RUN apt-get update && apt-get install -y \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Create a non-root user required by Hugging Face Spaces
RUN useradd -m -u 1000 user

# Copy requirements first to leverage Docker cache
COPY requirements.txt .

# Install Python dependencies
# We use --no-cache-dir to keep the image size small
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application code
COPY . .

# Create the storage directories explicitly and ensure appropriate permissions
RUN mkdir -p /app/storage/uploads /app/storage/processed
RUN chown -R user:user /app

# Switch to the non-root user
USER user

# Hugging Face Spaces exposes port 7860 by default
EXPOSE 7860

# Start the FastAPI application
# Hugging Face expects the server to run on 0.0.0.0:7860
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]