File size: 713 Bytes
09b5e1f
6e7ce30
 
09b5e1f
6e7ce30
 
09b5e1f
 
 
 
 
 
 
 
 
 
6e7ce30
 
09b5e1f
 
6e7ce30
09b5e1f
6e7ce30
 
09b5e1f
 
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
# Use a slim Python image for a smaller footprint
FROM python:3.11-slim

# Set the working directory
WORKDIR /app

# Create a non-root user for Hugging Face security
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"

# Copy requirements first to leverage Docker cache
# Use --chown=user:user to ensure the new user owns the files
COPY --chown=user:user requirements.txt .

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

# Copy the rest of the application code
COPY --chown=user:user . .

# Hugging Face Spaces listens on port 7860 by default
EXPOSE 7860

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