File size: 998 Bytes
2486f9d
 
 
5417c2e
 
 
2486f9d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Use the official Python 3.11 image
FROM python:3.11-slim

# Install ffmpeg for pydub audio processing
RUN apt-get update && apt-get install -y ffmpeg && rm -rf /var/lib/apt/lists/*

# Set up a non-root user (required by Hugging Face Spaces)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    PYTHONPATH=/home/user/app

# Set the working directory
WORKDIR $HOME/app

# Copy requirements and install them
# We switch back to root temporarily to fix permissions if needed, but pip install --user works fine for non-root
COPY --chown=user:user requirements.txt $HOME/app/
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir --user -r requirements.txt

# Copy the rest of the application code
COPY --chown=user:user . $HOME/app/

# Expose port 7860, which is what Hugging Face Spaces expects
EXPOSE 7860

# Start the FastAPI server on port 7860
CMD ["uvicorn", "src.api.main:app", "--host", "0.0.0.0", "--port", "7860"]