File size: 2,745 Bytes
f838f7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Custom docker image for AutomaTikZ, based on the default HF Spaces GPU image.
# The default image installs a tex live version that is too old for our needs,
# so we install the latest one oureselves. The modifications stay close to the
# source image, so, should the official image be updated to a newer ubuntu
# version, it could be changed back to a gradio space without much effort.

## system setup
# -----------------------------------------------------------------------------
FROM docker.io/nvidia/cuda:11.7.1-cudnn8-devel-ubuntu22.04@sha256:69cd988555eabe116f76acc754b363eee75f37674c23adb2b523f5fa32543984

ARG DEBIAN_FRONTEND=noninteractive

RUN 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 \
  ffmpeg \
  libsm6 \
  libxext6 \
  cmake \
  libgl1-mesa-glx \
  sudo

## setup user
# -----------------------------------------------------------------------------
RUN useradd -m -G users -u 1000 user

ENV HOME=/home/user \
  PATH=/home/user/.local/bin:$PATH

WORKDIR $HOME/app

## custom dependencies
# -----------------------------------------------------------------------------

# Install an up-to-date tex live version
ENV PATH=/opt/texbin:$PATH

RUN curl -LO https://github.com/scottkosty/install-tl-ubuntu/raw/master/install-tl-ubuntu \
  && chmod +x ./install-tl-ubuntu \
  && ./install-tl-ubuntu \
  && rm ./install-tl-ubuntu

RUN --mount=target=/root/packages.txt,source=packages.txt \
  apt-get update \
  && sed '/texlive*/d' /root/packages.txt \
  | xargs -r apt-get install -y \
  && rm -rf /var/lib/apt/lists/*

# Install pyenv
ENV PYENV_ROOT=/opt/pyenv
ENV PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH

RUN curl https://pyenv.run | bash \
  && chown -R root:users $PYENV_ROOT \
  && chmod -R g+w $PYENV_ROOT

RUN pyenv install 3.10 \
  && pyenv global 3.10 \
  && 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" "pydantic~=1.0"

RUN --mount=target=requirements.txt,source=requirements.txt \
  pip install --no-cache-dir -r requirements.txt

RUN --mount=target=pre-requirements.txt,source=pre-requirements.txt \
  pip install --no-cache-dir -r pre-requirements.txt

RUN pip install --no-cache-dir gradio[oauth]==3.47.1 uvicorn>=0.14.0 spaces==0.16.1

RUN chown -R user $HOME/app
COPY --chown=user . $HOME/app

## launch app
# -----------------------------------------------------------------------------
USER user

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