File size: 2,029 Bytes
dfb3b68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# syntax=docker/dockerfile:1.4
FROM docker.io/nvidia/cuda:11.7.1-cudnn8-devel-ubuntu20.04
ENV TZ=Asia/Tokyo
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN sed -i 's http://deb.debian.org http://cdn-aws.deb.debian.org g' /etc/apt/sources.list && \
    sed -i 's http://archive.ubuntu.com http://us-east-1.ec2.archive.ubuntu.com g' /etc/apt/sources.list && \
    sed -i '/security/d' /etc/apt/sources.list && apt-get update && \
    apt-get install -y \
        git \
        make build-essential libssl-dev zlib1g-dev \
        libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
        libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev git-lfs \
        ffmpeg libsm6 libxext6 cmake libgl1-mesa-glx \
        python3.9-dev cuda-cudart-11-7 && \
    rm -rf /var/lib/apt/lists/* && \
    git lfs install

RUN useradd -m -u 1000 user
USER user

RUN curl https://pyenv.run | bash
ENV PYENV_ROOT /home/user/.pyenv
ENV PATH ${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}
RUN eval "$(pyenv init -)" && \
    eval "$(pyenv virtualenv-init -)" && \
    pyenv install 3.9.7 && \
    pyenv global 3.9.7 && \
    pyenv rehash && \
    pip install --no-cache-dir --upgrade pip==22.3.1 setuptools wheel && \
    pip install --no-cache-dir datasets "huggingface-hub>=0.12.1" "protobuf<4" "click<8.1" && \
    curl -sSL https://install.python-poetry.org | python -
ENV PATH /home/user/.local/bin:${PATH}

COPY --link --chown=1000 ./pyproject.toml /home/user/app/pyproject.toml
COPY --link --chown=1000 ./model_pull.py /home/user/app/model_pull.py
WORKDIR /home/user/app

RUN poetry install
RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true \
    git config --global credential.helper store && \
    huggingface-cli login --token $(cat /run/secrets/HF_TOKEN) --add-to-git-credential
RUN poetry run python model_pull.py

COPY --link --chown=1000 ./app.py /home/user/app/app.py

EXPOSE 7860
ENTRYPOINT ["/home/user/.local/bin/poetry", "run", "python", "app.py"]