abc1181 commited on
Commit
19fd71d
·
verified ·
1 Parent(s): e319329

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -133
Dockerfile CHANGED
@@ -1,141 +1,28 @@
1
  FROM nvidia/cuda:11.3.1-base-ubuntu20.04
2
 
 
3
  ENV DEBIAN_FRONTEND=noninteractive \
4
- TZ=Aisa/Shanghai \
5
- LC_CTYPE=C.UTF-8 \
6
- LANG=C.UTF-8
7
-
8
- # Remove any third-party apt sources to avoid issues with expiring keys.
9
- # Install some basic utilities
10
- RUN rm -f /etc/apt/sources.list.d/*.list && \
11
- apt-get update && apt-get install -y \
12
- curl \
13
- ca-certificates \
14
- sudo \
15
- git \
16
- git-lfs \
17
- zip \
18
- unzip \
19
- htop \
20
- bzip2 \
21
- libx11-6 \
22
- nginx \
23
- vim \
24
- lsof \
25
- telnet \
26
- wget \
27
- build-essential \
28
- libsndfile-dev \
29
- software-properties-common \
30
- && rm -rf /var/lib/apt/lists/*
31
-
32
- ARG BUILD_DATE
33
- ARG VERSION
34
- ARG CODE_RELEASE
35
- RUN \
36
- echo "**** install openvscode-server runtime dependencies ****" && \
37
- apt-get update && \
38
- apt-get install -y \
39
- jq \
40
- libatomic1 \
41
- nano \
42
- net-tools \
43
- netcat && \
44
- echo "**** install openvscode-server ****" && \
45
- if [ -z ${CODE_RELEASE+x} ]; then \
46
- CODE_RELEASE=$(curl -sX GET "https://api.github.com/repos/gitpod-io/openvscode-server/releases/latest" \
47
- | awk '/tag_name/{print $4;exit}' FS='[""]' \
48
- | sed 's|^openvscode-server-v||'); \
49
- fi && \
50
- mkdir -p /app/openvscode-server && \
51
- curl -o \
52
- /tmp/openvscode-server.tar.gz -L \
53
- "https://github.com/gitpod-io/openvscode-server/releases/download/openvscode-server-v${CODE_RELEASE}/openvscode-server-v${CODE_RELEASE}-linux-x64.tar.gz" && \
54
- tar xf \
55
- /tmp/openvscode-server.tar.gz -C \
56
- /app/openvscode-server/ --strip-components=1 && \
57
- echo "**** clean up ****" && \
58
- apt-get clean && \
59
- rm -rf \
60
- /tmp/* \
61
- /var/lib/apt/lists/* \
62
- /var/tmp/*
63
- COPY root/ /
64
-
65
- RUN add-apt-repository ppa:flexiondotorg/nvtop && \
66
- apt-get upgrade -y && \
67
- apt-get install -y --no-install-recommends nvtop
68
-
69
- RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - && \
70
- apt-get install -y nodejs && \
71
- npm install -g configurable-http-proxy
72
-
73
- # Create a working directory
74
- WORKDIR /app
75
-
76
- # Create a non-root user and switch to it
77
- RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
78
- && chown -R user:user /app
79
- RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
80
- USER user
81
-
82
- # All users can use /home/user as their home directory
83
- ENV HOME=/home/user
84
- RUN mkdir $HOME/.cache $HOME/.config \
85
- && chmod -R 777 $HOME
86
-
87
- # Set up the Conda environment
88
- ENV CONDA_AUTO_UPDATE_CONDA=false \
89
- PATH=$HOME/miniconda/bin:$PATH
90
- RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py310_23.5.2-0-Linux-x86_64.sh \
91
- && chmod +x ~/miniconda.sh \
92
- && ~/miniconda.sh -b -p ~/miniconda \
93
- && rm ~/miniconda.sh \
94
- && conda clean -ya
95
-
96
- WORKDIR $HOME/app
97
-
98
- #######################################
99
- # Start root user section
100
- #######################################
101
-
102
- USER root
103
-
104
- # User Debian packages
105
- ## Security warning : Potential user code executed as root (build time)
106
- RUN --mount=target=/root/packages.txt,source=packages.txt \
107
- apt-get update && \
108
- xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
109
  && rm -rf /var/lib/apt/lists/*
110
 
111
- RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
112
- bash /root/on_startup.sh
113
-
114
- #######################################
115
- # End root user section
116
- #######################################
117
-
118
- USER user
119
-
120
- # Python packages
121
- RUN --mount=target=requirements.txt,source=requirements.txt \
122
- pip install --no-cache-dir --upgrade -r requirements.txt
123
-
124
- # Copy the current directory contents into the container at $HOME/app setting the owner to the user
125
- COPY --chown=user . $HOME/app
126
-
127
- WORKDIR $HOME/app
128
 
129
- RUN chmod +x start_server.sh
 
 
130
 
131
- ENV PYTHONUNBUFFERED=1 \
132
- GRADIO_ALLOW_FLAGGING=never \
133
- GRADIO_NUM_PORTS=1 \
134
- GRADIO_SERVER_NAME=0.0.0.0 \
135
- GRADIO_THEME=huggingface \
136
- SYSTEM=spaces \
137
- SHELL=/bin/bash
138
 
139
- EXPOSE 7860 3000
140
-
141
- CMD ["./start_server.sh"]
 
1
  FROM nvidia/cuda:11.3.1-base-ubuntu20.04
2
 
3
+ # Set root-level environment variables
4
  ENV DEBIAN_FRONTEND=noninteractive \
5
+ HOME=/root \
6
+ WORKDIR=/root/app
7
+
8
+ RUN apt-get update && apt-get install -y \
9
+ curl ca-certificates sudo git git-lfs zip unzip htop nginx vim wget build-essential \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Install openvscode-server directly into /opt or /root
13
+ RUN CODE_RELEASE=$(curl -sX GET "https://api.github.com/repos/gitpod-io/openvscode-server/releases/latest" | jq -r .tag_name | sed 's/openvscode-server-v//') && \
14
+ mkdir -p /opt/openvscode-server && \
15
+ curl -L "https://github.com/gitpod-io/openvscode-server/releases/download/openvscode-server-v${CODE_RELEASE}/openvscode-server-v${CODE_RELEASE}-linux-x64.tar.gz" | tar -xzC /opt/openvscode-server --strip-components=1
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
+ # Create the user but give them global sudo with no password
18
+ RUN useradd -m -u 1000 user && \
19
+ echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
20
 
21
+ # Setup the project in /root/app
22
+ WORKDIR /root/app
23
+ COPY . /root/app
24
+ RUN chmod -R 777 /root # High-level permission grant
 
 
 
25
 
26
+ # Switch to the mandatory HF user, but immediately sudo back to root in the CMD
27
+ USER user
28
+ CMD ["sudo", "-E", "bash", "start_server.sh"]