File size: 1,239 Bytes
3117187
 
4278031
 
 
 
f4fd0b5
 
6778b36
f4fd0b5
6778b36
3117187
4278031
6778b36
4278031
6778b36
 
4278031
 
 
 
aa8694c
3117187
 
4278031
3117187
4278031
3117187
4278031
 
f4fd0b5
4278031
 
 
3117187
4278031
 
90eb14c
4278031
 
3117187
4278031
 
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
FROM python:3.9-slim

# Create a non-root user
RUN useradd -m -u 1000 appuser

# Install system dependencies
RUN apt-get update && apt-get install -y \
    espeak-ng \
    git \
    libsndfile1 \
    curl

# Configure environment
ENV PYTHONUNBUFFERED=1 \
    HF_HOME=/home/appuser/cache \
    PYTHONPATH="/app"

# Create necessary directories and set permissions
RUN mkdir -p /app /home/appuser/cache /home/appuser/.local /home/appuser/.config/pulse && \
    chown -R appuser:appuser /app /home/appuser/cache /home/appuser/.local /home/appuser/.config && \
    chmod -R 755 /app /home/appuser/cache /home/appuser/.local /home/appuser/.config

WORKDIR /app

# Copy requirements first for better caching
COPY requirements.txt .
RUN chown appuser:appuser requirements.txt

# Switch to non-root user
USER appuser

# Install Python dependencies
RUN pip install --user --upgrade pip setuptools wheel && \
    pip install --user --no-cache-dir -r requirements.txt

# Install misaki from source (with data files)
RUN pip install --user git+https://github.com/hexgrad/misaki.git --no-cache-dir

# Copy application code
COPY --chown=appuser:appuser . .

# Run FastAPI
CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]