File size: 1,692 Bytes
b749c03
452cfe8
b749c03
 
 
 
452cfe8
b749c03
 
 
 
 
452cfe8
b749c03
 
 
452cfe8
 
b749c03
 
 
 
 
 
 
 
 
 
 
452cfe8
b749c03
452cfe8
b749c03
452cfe8
 
 
 
 
f96af93
 
452cfe8
 
 
 
ca9bb84
f96af93
b749c03
 
452cfe8
 
b749c03
452cfe8
 
 
 
 
 
 
b749c03
452cfe8
b749c03
452cfe8
 
b749c03
452cfe8
b749c03
 
452cfe8
b749c03
ca9bb84
452cfe8
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
FROM python:3.9-slim

ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PIP_NO_CACHE_DIR=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1

ENV HF_HOME=/tmp/huggingface_cache
ENV TRANSFORMERS_CACHE=/tmp/huggingface_cache/transformers
ENV HF_DATASETS_CACHE=/tmp/huggingface_cache/datasets
ENV TORCH_HOME=/tmp/torch_cache
ENV TOKENIZERS_PARALLELISM=false

ENV OMP_NUM_THREADS=1
ENV MKL_NUM_THREADS=1
ENV OPENBLAS_NUM_THREADS=1

# ---------- system deps ----------
RUN apt-get update && apt-get install -y \
    ffmpeg \
    libavcodec-extra \
    espeak-ng \
    alsa-utils \
    libasound2-dev \
    libsndfile1 \
    cmake \
    build-essential \
    pkg-config \
    gcc \
    g++ \
    curl \
    wget \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# ---------- python deps ----------
RUN pip install --no-cache-dir --upgrade pip setuptools wheel

RUN pip install --no-cache-dir sentencepiece

RUN pip install --no-cache-dir \
    torch==2.0.1 \
    torchaudio==2.0.2 \
    --index-url https://download.pytorch.org/whl/cpu


WORKDIR /code
COPY requirements.txt /code/requirements.txt

RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt && \
    pip cache purge && \
    rm -rf ~/.cache/pip /tmp/* /var/tmp/*

# ---------- caches ----------
RUN mkdir -p $HF_HOME $TORCH_HOME && \
    chmod -R 777 $HF_HOME $TORCH_HOME

# ---------- app ----------
COPY . /code/

RUN useradd --create-home --shell /bin/bash app && \
    chown -R app:app /code $HF_HOME $TORCH_HOME

USER app

HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
    CMD curl -f http://localhost:7860/health || exit 1

EXPOSE 7860

CMD ["python", "-u", "app.py"]