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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Give me an analysis on what this dockerfile does: 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 \
|
| 10 |
+
curl \
|
| 11 |
+
ca-certificates \
|
| 12 |
+
sudo \
|
| 13 |
+
git \
|
| 14 |
+
git-lfs \
|
| 15 |
+
zip \
|
| 16 |
+
unzip \
|
| 17 |
+
htop \
|
| 18 |
+
bzip2 \
|
| 19 |
+
libx11-6 \
|
| 20 |
+
build-essential \
|
| 21 |
+
libsndfile-dev \
|
| 22 |
+
software-properties-common \
|
| 23 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 24 |
+
|
| 25 |
+
ARG BUILD_DATE
|
| 26 |
+
ARG VERSION
|
| 27 |
+
ARG CODE_RELEASE
|
| 28 |
+
RUN \
|
| 29 |
+
echo "**** install openvscode-server runtime dependencies ****" && \
|
| 30 |
+
apt-get update && \
|
| 31 |
+
apt-get install -y \
|
| 32 |
+
jq \
|
| 33 |
+
libatomic1 \
|
| 34 |
+
nano \
|
| 35 |
+
net-tools \
|
| 36 |
+
netcat && \
|
| 37 |
+
echo "**** install openvscode-server ****" && \
|
| 38 |
+
if [ -z ${CODE_RELEASE+x} ]; then \
|
| 39 |
+
CODE_RELEASE=$(curl -sX GET "https://api.github.com/repos/gitpod-io/openvscode-server/releases/latest" \
|
| 40 |
+
| awk '/tag_name/{print $4;exit}' FS='[""]' \
|
| 41 |
+
| sed 's|^openvscode-server-v||'); \
|
| 42 |
+
fi && \
|
| 43 |
+
mkdir -p /app/openvscode-server && \
|
| 44 |
+
curl -o \
|
| 45 |
+
/tmp/openvscode-server.tar.gz -L \
|
| 46 |
+
"https://github.com/gitpod-io/openvscode-server/releases/download/openvscode-server-v${CODE_RELEASE}/openvscode-server-v${CODE_RELEASE}-linux-x64.tar.gz" && \
|
| 47 |
+
tar xf \
|
| 48 |
+
/tmp/openvscode-server.tar.gz -C \
|
| 49 |
+
/app/openvscode-server/ --strip-components=1 && \
|
| 50 |
+
echo "**** clean up ****" && \
|
| 51 |
+
apt-get clean && \
|
| 52 |
+
rm -rf \
|
| 53 |
+
/tmp/* \
|
| 54 |
+
/var/lib/apt/lists/* \
|
| 55 |
+
/var/tmp/*
|
| 56 |
+
COPY root/ /
|
| 57 |
+
|
| 58 |
+
RUN add-apt-repository ppa:flexiondotorg/nvtop && \
|
| 59 |
+
apt-get upgrade -y && \
|
| 60 |
+
apt-get install -y --no-install-recommends nvtop
|
| 61 |
+
|
| 62 |
+
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
|
| 63 |
+
apt-get install -y nodejs && \
|
| 64 |
+
npm install -g configurable-http-proxy
|
| 65 |
+
# Create a working directory
|
| 66 |
+
WORKDIR /app
|
| 67 |
+
# Create a non-root user and switch to it
|
| 68 |
+
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
|
| 69 |
+
&& chown -R user:user /app
|
| 70 |
+
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
|
| 71 |
+
USER user
|
| 72 |
+
# All users can use /home/user as their home directory
|
| 73 |
+
ENV HOME=/home/user
|
| 74 |
+
RUN mkdir $HOME/.cache $HOME/.config \
|
| 75 |
+
&& chmod -R 777 $HOME
|
| 76 |
+
# Set up the Conda environment
|
| 77 |
+
ENV CONDA_AUTO_UPDATE_CONDA=false \
|
| 78 |
+
PATH=$HOME/miniconda/bin:$PATH
|
| 79 |
+
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh \
|
| 80 |
+
&& chmod +x ~/miniconda.sh \
|
| 81 |
+
&& ~/miniconda.sh -b -p ~/miniconda \
|
| 82 |
+
&& rm ~/miniconda.sh \
|
| 83 |
+
&& conda clean -ya
|
| 84 |
+
|
| 85 |
+
WORKDIR $HOME/app
|
| 86 |
+
|
| 87 |
+
#######################################
|
| 88 |
+
# Start root user section
|
| 89 |
+
#######################################
|
| 90 |
+
|
| 91 |
+
USER root
|
| 92 |
+
|
| 93 |
+
# User Debian packages
|
| 94 |
+
## Security warning : Potential user code executed as root (build time)
|
| 95 |
+
RUN --mount=target=/root/packages.txt,source=packages.txt \
|
| 96 |
+
apt-get update && \
|
| 97 |
+
xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
|
| 98 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 99 |
+
|
| 100 |
+
RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
|
| 101 |
+
bash /root/on_startup.sh
|
| 102 |
+
|
| 103 |
+
#######################################
|
| 104 |
+
# End root user section
|
| 105 |
+
#######################################
|
| 106 |
+
|
| 107 |
+
USER user
|
| 108 |
+
|
| 109 |
+
# Python packages
|
| 110 |
+
RUN --mount=target=requirements.txt,source=requirements.txt \
|
| 111 |
+
pip install --no-cache-dir --upgrade -r requirements.txt
|
| 112 |
+
|
| 113 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 114 |
+
COPY --chown=user . $HOME/app
|
| 115 |
+
|
| 116 |
+
RUN chmod +x start_server.sh
|
| 117 |
+
|
| 118 |
+
ENV PYTHONUNBUFFERED=1 \
|
| 119 |
+
GRADIO_ALLOW_FLAGGING=never \
|
| 120 |
+
GRADIO_NUM_PORTS=1 \
|
| 121 |
+
GRADIO_SERVER_NAME=0.0.0.0 \
|
| 122 |
+
GRADIO_THEME=huggingface \
|
| 123 |
+
SYSTEM=spaces \
|
| 124 |
+
SHELL=/bin/bash
|
| 125 |
+
|
| 126 |
+
EXPOSE 7860 3000
|
| 127 |
+
|
| 128 |
+
CMD ["./start_server.sh"]
|
| 129 |
+
This Dockerfile describes the steps to create a Docker image with an environment that includes various tools, libraries, and applications. The image is based on the nvidia/cuda:11.3.1-base-ubuntu20.04 image, which is a Ubuntu 20.04 base image with NVIDIA CUDA 11.3.1 libraries pre-installed. The steps in this Dockerfile can be broken down as follows:
|
| 130 |
+
|
| 131 |
+
Set environment variables:
|
| 132 |
+
|
| 133 |
+
Set the timezone to Europe/Paris
|
| 134 |
+
Set the Debian frontend to noninteractive mode for silent installations
|
| 135 |
+
Remove third-party apt sources to avoid issues with expiring keys.
|
| 136 |
+
|
| 137 |
+
Install basic utilities and libraries using apt-get.
|
| 138 |
+
|
| 139 |
+
Install the OpenVSCode-Server, which is an open-source version of VSCode Server, allowing you to run a remote VSCode environment.
|
| 140 |
+
|
| 141 |
+
Add the flexiondotorg/nvtop repository and install the NVTop GPU monitoring tool.
|
| 142 |
+
|
| 143 |
+
Install Node.js 14.x and the configurable-http-proxy package.
|
| 144 |
+
|
| 145 |
+
Create a non-root user named user and set appropriate permissions.
|
| 146 |
+
|
| 147 |
+
Set up the Conda environment with Miniconda3 and Python 3.9.
|
| 148 |
+
|
| 149 |
+
Install user-specified Debian packages by reading from a packages.txt file.
|
| 150 |
+
|
| 151 |
+
Execute a script named on_startup.sh as the root user.
|
| 152 |
+
|
| 153 |
+
Switch back to the non-root user user.
|
| 154 |
+
|
| 155 |
+
Install Python packages specified in a requirements.txt file.
|
| 156 |
+
|
| 157 |
+
Copy the current directory contents into the container at $HOME/app.
|
| 158 |
+
|
| 159 |
+
Set environment variables for Gradio and other configurations.
|
| 160 |
+
|
| 161 |
+
Expose ports 7860 and 3000.
|
| 162 |
+
|
| 163 |
+
Set the CMD to execute the start_server.sh script when the container starts.
|
| 164 |
+
|
| 165 |
+
This Dockerfile sets up a development environment with NVIDIA CUDA support, a Conda environment, OpenVSCode-Server, NVTop, and various other utilities. It also installs user-specified Debian and Python packages, and runs a user-specified script at startup. The image is prepared to run a server using Gradio, a library for creating web-based UIs for ML models, and exposes two ports for external communication.
|