File size: 914 Bytes
b4343ae
 
 
6ee9d08
 
b4343ae
 
 
 
6ee9d08
580707c
 
 
 
fc80c4a
6ee9d08
9d345dc
b4343ae
6ee9d08
9d345dc
b4343ae
 
6ee9d08
 
b4343ae
6ee9d08
 
 
 
 
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
# 1. Start with a lean and official Python base image
FROM python:3.10-slim

# Install dependencies for psycopg2 and audio processing
RUN apt-get update && apt-get install -y libpq-dev ffmpeg && rm -rf /var/lib/apt/lists/*

# 2. Set the working directory inside the container
WORKDIR /app

# 3. Create a non-root user and set up cache
RUN useradd -m -u 1000 user
RUN mkdir -p /app/.cache && chown -R user:user /app/.cache
ENV HF_HOME="/app/.cache"
USER user

# Add local bin directory to PATH
ENV PATH="/home/user/.local/bin:${PATH}"

# 4. Copy and install dependencies
COPY --chown=user:user requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# 5. Copy the app source code
COPY --chown=user:user . .

# 6. Expose the port used by Hugging Face Spaces
EXPOSE 7860

# 7. Run the FastAPI app using Uvicorn (better for WebSockets)
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]