File size: 1,063 Bytes
515a3fb
976f9a1
515a3fb
 
976f9a1
515a3fb
 
 
976f9a1
515a3fb
 
 
 
 
 
 
976f9a1
515a3fb
 
976f9a1
515a3fb
 
 
976f9a1
515a3fb
 
 
 
 
976f9a1
515a3fb
 
976f9a1
515a3fb
 
 
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
FROM python:3.10-slim

# Set working directory
WORKDIR /app

# Set environment variables to prevent pyc files and buffer output
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1

# Install system dependencies (if any are needed for specific python packages)
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements from backend
COPY backend/requirements.txt /app/requirements.txt

# Install dependencies
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt

# Copy the backend code
COPY backend /app/backend
# We do not copy the legacy main.py from root to enable clean separation

# Create a non-root user (Hugging Face Spaces requirement)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Expose the port HF Spaces uses (7860)
EXPOSE 7860

# Command to run the application
# We use uvicorn to run the app found in backend.main:app
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]