AROZOS / Dockerfile
azils3's picture
Update Dockerfile
b86695f verified
FROM nvidia/cuda:12.2.0-devel-ubuntu22.04
# Install necessary packages
RUN apt update && \
apt install -y --no-install-recommends \
curl \
git \
git-lfs \
libatomic1 \
locales \
man \
nano \
net-tools \
netcat \
openssh-client \
python3 \
python3-pip \
python3-venv \
sudo \
vim \
wget \
zsh \
zip \
unzip \
ffmpeg \
imagemagick \
software-properties-common \
&& git lfs install \
&& rm -rf /var/lib/apt/lists/*
# Fix ImageMagick policy
RUN sed -i '/<policy domain="path" rights="none" pattern="@\*"/d' /etc/ImageMagick-6/policy.xml
# Set working directory
WORKDIR /home/
# Environment variables
ENV USERNAME=user \
USER_UID=1000 \
USER_GID=1000 \
LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
NVIDIA_VISIBLE_DEVICES=all \
NVIDIA_DRIVER_CAPABILITIES=all \
EDITOR=code \
VISUAL=code \
GIT_EDITOR="code --wait" \
OPENVSCODE_SERVER_ROOT=/home/.vscode \
OPENVSCODE=/home/.vscode/bin/openvscode-server \
PATH="/home/user/.local/bin:$PATH"
# Download and install OpenVSCode Server
RUN RELEASE_TAG=$(curl -sX GET "https://api.github.com/repos/gitpod-io/openvscode-server/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]') && \
arch=$(uname -m) && \
if [ "${arch}" = "x86_64" ]; then \
arch="x64"; \
elif [ "${arch}" = "aarch64" ]; then \
arch="arm64"; \
elif [ "${arch}" = "armv7l" ]; then \
arch="armhf"; \
fi && \
wget https://github.com/gitpod-io/openvscode-server/releases/download/${RELEASE_TAG}/${RELEASE_TAG}-linux-${arch}.tar.gz && \
tar -xzf ${RELEASE_TAG}-linux-${arch}.tar.gz && \
mv ${RELEASE_TAG}-linux-${arch} ${OPENVSCODE_SERVER_ROOT} && \
cp ${OPENVSCODE_SERVER_ROOT}/bin/remote-cli/openvscode-server ${OPENVSCODE_SERVER_ROOT}/bin/remote-cli/code && \
rm -f ${RELEASE_TAG}-linux-${arch}.tar.gz
# Install Firefox within VS-code
RUN install -d -m 0755 /etc/apt/keyrings && \
wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null && \
gpg -n -q --import --import-options import-show /etc/apt/keyrings/packages.mozilla.org.asc | awk '/pub/{getline; gsub(/^ +| +$/,""); if($0 == "35BAA0B33E9EB396F59CA838C0BA5CE6DC6315A3") print "\nThe key fingerprint matches ("$0").\n"; else print "\nVerification failed: the fingerprint ("$0") does not match the expected one.\n"}' && \
echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" | tee -a /etc/apt/sources.list.d/mozilla.list > /dev/null && \
echo 'Package: *\nPin: origin packages.mozilla.org\nPin-Priority: 1000\n' | tee /etc/apt/preferences.d/mozilla && \
apt-get update && \
apt-get install -y firefox
# Download and install GeckoDriver for x86_64 architecture
RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.34.0/geckodriver-v0.34.0-linux64.tar.gz && \
tar -xvzf geckodriver-v0.34.0-linux64.tar.gz && \
sudo mv geckodriver /usr/local/bin/ && \
sudo chmod +x /usr/local/bin/geckodriver && \
geckodriver --version
# Install PDM
RUN curl -sSL https://pdm-project.org/install-pdm.py | python3 -
# Set working directory for user
WORKDIR /home/user/
# Create user and usergroup
RUN groupadd --gid ${USER_GID} ${USERNAME} \
&& useradd --uid ${USER_UID} --gid ${USERNAME} -m -s /bin/bash ${USERNAME} \
&& echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} \
&& chmod 0440 /etc/sudoers.d/${USERNAME}
# Set permissions
RUN chmod g+rw /home && \
chown -R ${USERNAME}:${USERNAME} ${OPENVSCODE_SERVER_ROOT} && \
chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}
# Switch to user
USER $USERNAME
# Install oh-my-zsh & Init
RUN yes | sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Install VSCode Extensions
RUN ${OPENVSCODE} --install-extension ms-python.python && \
${OPENVSCODE} --install-extension monokai.theme-monokai-pro-vscode
# Install python packages
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt && \
rm -rf requirements.txt
# Entry point
ENTRYPOINT ["/bin/sh", "-c", "exec $OPENVSCODE --host 0.0.0.0 --port 7860 --without-connection-token"]