tengel commited on
Commit
ea10ffa
·
verified ·
1 Parent(s): c127fce

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +107 -0
Dockerfile ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nvidia/cuda:11.3.1-base-ubuntu20.04
2
+
3
+ ENV DEBIAN_FRONTEND=noninteractive \
4
+ TZ=Europe/Paris
5
+
6
+ # Remove any third-party apt sources to avoid issues with expiring keys.
7
+ # Install some basic utilities
8
+ RUN rm -f /etc/apt/sources.list.d/*.list && \
9
+ apt-get update && apt-get install -y --no-install-recommends \
10
+ curl \
11
+ ca-certificates \
12
+ sudo \
13
+ git \
14
+ wget \
15
+ procps \
16
+ git-lfs \
17
+ zip \
18
+ unzip \
19
+ htop \
20
+ vim \
21
+ nano \
22
+ bzip2 \
23
+ libx11-6 \
24
+ build-essential \
25
+ libsndfile-dev \
26
+ software-properties-common \
27
+ rsync \
28
+ && rm -rf /var/lib/apt/lists/*
29
+
30
+ RUN add-apt-repository ppa:flexiondotorg/nvtop && \
31
+ apt-get upgrade -y && \
32
+ apt-get install -y --no-install-recommends nvtop
33
+
34
+ RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
35
+ apt-get install -y nodejs && \
36
+ npm install -g configurable-http-proxy
37
+
38
+ # Create a working directory
39
+ WORKDIR /app
40
+
41
+ # Create a non-root user and switch to it
42
+ RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
43
+ && chown -R user:user /app
44
+ RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
45
+ USER user
46
+
47
+ # All users can use /home/user as their home directory
48
+ ENV HOME=/home/user
49
+ RUN mkdir $HOME/.cache $HOME/.config \
50
+ && chmod -R 777 $HOME
51
+
52
+ # Set up the Conda environment
53
+ ENV CONDA_AUTO_UPDATE_CONDA=false \
54
+ PATH=$HOME/miniconda/bin:$PATH
55
+ RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh \
56
+ && chmod +x ~/miniconda.sh \
57
+ && ~/miniconda.sh -b -p ~/miniconda \
58
+ && rm ~/miniconda.sh \
59
+ && conda clean -ya
60
+
61
+ WORKDIR $HOME/app
62
+
63
+ #######################################
64
+ # Start root user section
65
+ #######################################
66
+
67
+ USER root
68
+
69
+ # User Debian packages
70
+ ## Security warning : Potential user code executed as root (build time)
71
+ RUN --mount=target=/root/packages.txt,source=packages.txt \
72
+ apt-get update && \
73
+ xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
74
+ && rm -rf /var/lib/apt/lists/*
75
+
76
+ RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
77
+ bash /root/on_startup.sh
78
+
79
+ RUN mkdir /data && chown user:user /data
80
+ RUN ln -s $HOME/app /data/repository
81
+
82
+ #######################################
83
+ # End root user section
84
+ #######################################
85
+
86
+ USER user
87
+
88
+ # Python packages
89
+ RUN --mount=target=requirements.txt,source=requirements.txt \
90
+ pip install --no-cache-dir --upgrade -r requirements.txt
91
+
92
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
93
+ COPY --chown=user . $HOME/app
94
+
95
+ RUN chmod +x start_server.sh
96
+
97
+ COPY --chown=user login.html /home/user/miniconda/lib/python3.9/site-packages/jupyter_server/templates/login.html
98
+
99
+ ENV PYTHONUNBUFFERED=1 \
100
+ GRADIO_ALLOW_FLAGGING=never \
101
+ GRADIO_NUM_PORTS=1 \
102
+ GRADIO_SERVER_NAME=0.0.0.0 \
103
+ GRADIO_THEME=huggingface \
104
+ SYSTEM=spaces \
105
+ SHELL=/bin/bash
106
+
107
+ CMD ["./start_server.sh"]