File size: 853 Bytes
30c6ade
c2fb4c6
 
30c6ade
c2fb4c6
 
30c6ade
 
 
 
c2fb4c6
 
 
30c6ade
 
 
 
 
 
c2fb4c6
 
 
30c6ade
c2fb4c6
 
30c6ade
c2fb4c6
 
30c6ade
c2fb4c6
 
30c6ade
c2fb4c6
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
# Use Python 3.12
FROM python:3.12

# Set the working directory (Created as root by default)
WORKDIR /app

# Create the user (ID 1000 is required for HF Spaces)
RUN useradd -m -u 1000 user

# Copy requirements and install (Run as root to install globally or easily)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# --- CRITICAL FIX ---
# Change ownership of the working directory to the user
RUN chown user:user /app
# --------------------

# Switch to the non-root user
USER user
ENV PATH="/home/user/.local/bin:$PATH"

# Copy the rest of the application code with correct ownership
COPY --chown=user . .

# Run the setup script (Now has permission to write to /app/models)
RUN python setup_models.py

# Expose the port
EXPOSE 7860

# Start the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]