File size: 2,650 Bytes
0890591
89e5b6e
 
a1de45c
 
 
 
 
 
 
 
 
 
 
 
 
e6cea19
 
89e5b6e
 
 
 
e0c15f9
 
89e5b6e
 
 
 
e0c15f9
 
89e5b6e
 
 
 
 
 
 
a1de45c
e6cea19
a1de45c
 
 
89e5b6e
a1de45c
 
 
e6cea19
a1de45c
 
89e5b6e
a1de45c
89e5b6e
 
a1de45c
 
 
 
 
89e5b6e
a1de45c
 
 
 
 
 
89e5b6e
a1de45c
89e5b6e
a1de45c
89e5b6e
 
e6cea19
 
a1de45c
 
89e5b6e
e6cea19
a1de45c
89e5b6e
a1de45c
89e5b6e
e6cea19
a1de45c
e6cea19
 
 
a1de45c
 
89e5b6e
a1de45c
89e5b6e
a1de45c
 
89e5b6e
e6cea19
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
FROM nvidia/cuda:12.5.1-cudnn-devel-ubuntu20.04

ENV DEBIAN_FRONTEND=noninteractive \
    TZ=Europe/Paris \
    CONDA_AUTO_UPDATE_CONDA=false \
    HOME=/home/user \
    PATH=/home/user/miniconda/bin:$PATH \
    PYTHONUNBUFFERED=1 \
    GRADIO_ALLOW_FLAGGING=never \
    GRADIO_NUM_PORTS=1 \
    GRADIO_SERVER_NAME=0.0.0.0 \
    GRADIO_THEME=huggingface \
    SYSTEM=spaces \
    SHELL=/bin/bash

# Base utilities
RUN rm -f /etc/apt/sources.list.d/*.list && \
    apt-get update && apt-get install -y --no-install-recommends \
    curl \
    ca-certificates \
    sudo \
    git \
    wget \
    procps \
    git-lfs \
    zip \
    unzip \
    htop \
    vim \
    nano \
    bzip2 \
    libx11-6 \
    build-essential \
    libsndfile-dev \
    software-properties-common \
 && rm -rf /var/lib/apt/lists/*

# nvtop
RUN add-apt-repository ppa:flexiondotorg/nvtop && \
    apt-get update && \
    apt-get install -y --no-install-recommends nvtop && \
    rm -rf /var/lib/apt/lists/*

# Node.js 21
RUN curl -fsSL https://deb.nodesource.com/setup_21.x | bash - && \
    apt-get update && \
    apt-get install -y nodejs && \
    npm install -g configurable-http-proxy && \
    rm -rf /var/lib/apt/lists/*

# Working directory
WORKDIR /app

# User setup
RUN adduser --disabled-password --gecos '' --shell /bin/bash user && \
    mkdir -p /home/user/.cache /home/user/.config /home/user/app && \
    chown -R user:user /home/user /app && \
    echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user

# Miniconda Python 3.10
USER user
RUN curl -fsSL -o /home/user/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-py310_22.11.1-1-Linux-x86_64.sh && \
    bash /home/user/miniconda.sh -b -p /home/user/miniconda && \
    rm -f /home/user/miniconda.sh && \
    conda clean -ya

WORKDIR /home/user/app

# Back to root for system packages / startup
USER root

RUN --mount=target=/root/packages.txt,source=packages.txt \
    apt-get update && \
    xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends && \
    rm -rf /var/lib/apt/lists/*

RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
    bash /root/on_startup.sh

RUN mkdir -p /data && chown user:user /data

# Python packages
USER user
RUN --mount=target=requirements.txt,source=requirements.txt \
    pip install --no-cache-dir --upgrade -r requirements.txt

# App files
COPY --chown=user:user . /home/user/app

RUN chmod +x /home/user/app/start_server.sh

# Jupyter template path for Python 3.10
COPY --chown=user:user login.html /home/user/miniconda/lib/python3.10/site-packages/jupyter_server/templates/login.html

CMD ["./start_server.sh"]