File size: 3,378 Bytes
aa7cb02
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ef46c24
 
 
 
b941e8b
add0ca0
ef46c24
e1c3caf
 
61354cd
c10d29b
aa7cb02
81b0f36
 
 
 
aa7cb02
 
 
 
 
 
 
 
 
ef46c24
 
b941e8b
ef46c24
aa7cb02
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c3ea709
 
 
aa7cb02
 
 
 
 
 
 
 
 
 
 
8e69b04
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Use an official CUDA-enabled image from NVIDIA with CUDA 12.1
FROM nvidia/cuda:12.1.1-cudnn8-devel-ubuntu20.04

# Set the working directory in the container
WORKDIR /app

# Set the environment variable to suppress interactive prompts
ENV DEBIAN_FRONTEND=noninteractive

# Install necessary OS packages and Python 3.9
RUN apt-get update && apt-get install -y \
    software-properties-common \
    && add-apt-repository ppa:deadsnakes/ppa \
    && apt-get update && apt-get install -y \
    python3.9 \
    python3.9-distutils \
    python3.9-venv \
    python3.9-dev \
    build-essential \
    cmake \
    libsndfile1 \
    ffmpeg \
    portaudio19-dev \
    alsa-utils \
    curl \
    git \
    nodejs \
    npm \
    && rm -rf /var/lib/apt/lists/*

# Install pip for Python 3.9
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.9

# Create a symlink for python3.9 and pip3.9
RUN ln -s /usr/bin/python3.9 /usr/bin/python
RUN ln -s /usr/local/bin/pip /usr/bin/pip

# Set CUDA_HOME environment variable
ENV CUDA_HOME=/usr/local/cuda

# Add CUDA to PATH
ENV PATH=${CUDA_HOME}/bin:${PATH}

# Optionally set LD_LIBRARY_PATH for CUDA libraries
ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}

# Create cache directories with proper permissions
RUN mkdir -p /app/cache/huggingface && \
    mkdir -p /app/cache/triton && \
    mkdir -p /app/cache/torch_extensions && \
    chmod -R 777 /app/cache

# Set environment variables for cache directories
ENV HF_HOME=/app/cache/huggingface
ENV TRANSFORMERS_CACHE=/app/cache/huggingface
ENV TRITON_CACHE_DIR=/app/cache/triton
ENV TORCH_EXTENSIONS_DIR=/app/cache/torch_extensions

# Disable numba caching
ENV NUMBA_CACHE_DIR=/tmp/numba_cache
ENV NUMBA_DISABLE_JIT=1

# Copy the setup script and requirements file into the container
COPY setup.sh requirements.txt /app/

# Make the setup script executable
RUN chmod +x setup.sh

# Copy the application code into the container
COPY . /app

# Create necessary directories for Node.js uploads with proper permissions
RUN mkdir -p /app/app/uploads && chmod -R 777 /app/app/uploads
RUN mkdir -p /app/app/public && chmod -R 777 /app/app/public

# Copy wait-for-it script
COPY wait-for-it.sh /app/wait-for-it.sh

# Make wait-for-it script executable
RUN chmod +x /app/wait-for-it.sh

# Install dependencies
RUN pip install --upgrade pip setuptools wheel
RUN pip install pybind11
RUN pip install fasttext
RUN pip install Cython
RUN pip install pyaudio
RUN pip install fastapi uvicorn
RUN pip install uvloop

# Install PyTorch and torchaudio
RUN pip install torch==2.2.2+cu121 -f https://download.pytorch.org/whl/cu121/torch_stable.html
RUN pip install torchaudio==2.2.2+cu121 -f https://download.pytorch.org/whl/cu121/torch_stable.html

# Install the requirements
RUN pip install -r requirements.txt

# Clone and install TTS
RUN git clone https://github.com/coqui-ai/TTS/ && \
    cd TTS && \
    make install

# Ensure the correct version of librosa is installed
RUN pip install librosa==0.9.2

# Install Node.js dependencies
RUN cd /app/app && npm install

# Expose the ports
EXPOSE 8000
EXPOSE 3000

# Set the environment variable to indicate running in Docker
ENV IN_DOCKER=True

# Run the FastAPI app and Node.js server
CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port 8000 & /app/wait-for-it.sh --url http://0.0.0.0:8000/health --strict -- node /app/app/server.js"]