File size: 1,130 Bytes
94fd4b0
9a88d9c
703fff1
 
9a88d9c
94fd4b0
a7aae29
 
 
 
 
9a88d9c
 
 
 
703fff1
 
 
94fd4b0
703fff1
 
a7aae29
94fd4b0
703fff1
94fd4b0
703fff1
 
94fd4b0
703fff1
9a88d9c
94fd4b0
703fff1
 
9a88d9c
94fd4b0
f81b911
a7aae29
94fd4b0
 
9a88d9c
 
bbaf488
9a88d9c
94fd4b0
 
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
45
FROM python:3.11-slim

# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user

# Install only essential system dependencies
RUN apt-get update && apt-get install -y \
    git \
    git-lfs \
    ffmpeg \
    && rm -rf /var/lib/apt/lists/*

# Initialize git lfs
RUN git lfs install

# Switch to the "user" user
USER user

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

# Set the working directory
WORKDIR $HOME/app

# Upgrade pip
RUN pip install --no-cache-dir --upgrade pip

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

# Pre-download the C-3PO model to speed up startup
RUN python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='Xerror/XTTS-v2_C3PO', local_dir='./models/XTTS-v2_C3PO', local_dir_use_symlinks=False)"

# Copy the API file
COPY --chown=user coqui_api.py .

# Expose the port
EXPOSE 7860

# Start the C-3PO TTS API
CMD ["uvicorn", "coqui_api:app", "--host", "0.0.0.0", "--port", "7860"]