File size: 1,338 Bytes
13d62bd
 
 
449b23e
 
 
7111ecb
 
 
13d62bd
 
 
daa0137
 
13d62bd
 
 
 
5d4c1d3
 
 
 
 
13d62bd
 
 
 
 
 
 
 
 
5d4c1d3
13d62bd
 
a1be075
 
13d62bd
 
 
 
 
f2a9bb4
 
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
# 1. 選擇一個包含 Python 的官方 Linux 映像
FROM python:3.10-slim

ENV HF_HOME=/tmp/huggingface
ENV HF_DATASETS_CACHE=/tmp/huggingface/datasets

#  為 MeCab 設定正確的設定檔路徑,解決 "no such file or directory" 錯誤
ENV MECABRC=/etc/mecabrc

# 2. 設定容器內的工作目錄
WORKDIR /app

ENV NUMBA_CACHE_DIR=/tmp

# 3. 安裝系統級依賴 (最關鍵的一步:安裝 espeak-ng、git 和其他工具)
#    -y 自動回答 'yes'
#    --no-install-recommends 避免安裝不必要的建議套件,保持映像檔小巧
RUN apt-get update && apt-get install -y --no-install-recommends \

    build-essential \
    cmake \
    mecab \
    libmecab-dev \
    mecab-ipadic-utf8 \
    espeak-ng \
    libsndfile1 \
    ffmpeg \
    wget \
    git && \
    rm -rf /var/lib/apt/lists/*

# 4. 複製 requirements.txt 檔案到容器中並安裝 Python 套件
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt

RUN python -c "import pyopenjtalk; pyopenjtalk.g2p('test')"

# 5. 將專案中的所有其他檔案複製到容器中
COPY . .

# 這行是可選的,它設定了當容器直接執行時的預設命令
# CMD ["python", "your_script.py"]

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]