File size: 1,278 Bytes
8fc136c
 
3fc4dbc
8fc136c
 
 
 
 
3fc4dbc
8fc136c
3fc4dbc
 
 
 
8fc136c
 
3fc4dbc
 
8fc136c
 
 
 
3fc4dbc
8fc136c
 
 
 
 
3fc4dbc
8fc136c
 
3fc4dbc
8fc136c
 
3fc4dbc
8fc136c
 
341ae9e
8fc136c
53b0a64
8fc136c
8e632ab
 
 
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
37
38
39
40
41
42
43
44
# Using 3.12-slim is safer as many AI wheels for 3.13 are still unstable
FROM python:3.12-slim

# 1. Set environment variables
ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# 2. Install essential system/audio libraries
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    git \
    ffmpeg \
    libsndfile1 \
    && rm -rf /var/lib/apt/lists/*

# 3. Create the mandatory HF non-root user
RUN useradd -m -u 1000 user
USER user
WORKDIR $HOME/app

# 4. Install requirements
# Copy requirements first for better caching
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# 5. Copy the code (Keeping your src/ structure)
COPY --chown=user src/ ./src/

# 6. Expose the CORRECT Hugging Face port
EXPOSE 7860

# 7. Entrypoint with Port 7860 and XSRF fixes
# Note: We call src/streamlit_app.py because we copied the folder itself
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", \
    "--server.port=7860", \
    "--server.address=0.0.0.0", \
    "--server.enableXsrfProtection=false", \
    "--server.enableCORS=false", \
    "--server.headless=true", \
    "--browser.gatherUsageStats=false"]