-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use heredocs for multi-line script.
- Loading branch information
Showing
1 changed file
with
48 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# syntax=docker/dockerfile:1.4 | ||
FROM rubensa/ubuntu-tini-dev | ||
LABEL author="Ruben Suarez <[email protected]>" | ||
|
||
|
@@ -27,47 +28,65 @@ ENV DEBIAN_FRONTEND=noninteractive | |
RUN apt-get update | ||
|
||
# Install Google Noto font family | ||
RUN echo "# Installing Google Noto font family..." \ | ||
&& apt-get -y install fonts-noto 2>&1 | ||
RUN <<EOT | ||
echo "# Installing Google Noto font family..." | ||
apt-get -y install fonts-noto 2>&1 | ||
EOT | ||
|
||
# Install software and libraries needed to share X11 between host and container | ||
RUN echo "# Installing kmod, libglib2.0-bin, libgl1, libglx-mesa0, libgl1-mesa-dri, pulseaudio-utils, cups-client, x11-utils, mesa-utils, mesa-utils-extra and va-driver-all..." \ | ||
&& apt-get -y install --no-install-recommends kmod libglib2.0-bin libgl1 libglx-mesa0 libgl1-mesa-dri pulseaudio-utils cups-client x11-utils mesa-utils mesa-utils-extra va-driver-all 2>&1 | ||
RUN <<EOT | ||
echo "# Installing kmod, libglib2.0-bin, libgl1, libglx-mesa0, libgl1-mesa-dri, pulseaudio-utils, cups-client, x11-utils, mesa-utils, mesa-utils-extra and va-driver-all..." | ||
apt-get -y install --no-install-recommends kmod libglib2.0-bin libgl1 libglx-mesa0 libgl1-mesa-dri pulseaudio-utils cups-client x11-utils mesa-utils mesa-utils-extra va-driver-all 2>&1 | ||
EOT | ||
|
||
# Configure user (add to audio and video groups) | ||
RUN echo "# Configuring '${USER_NAME}' for X11 functionallity..." \ | ||
# | ||
# Assign audio group to non-root user | ||
&& usermod -a -G audio ${USER_NAME} \ | ||
# | ||
# Assign video group to non-root user | ||
&& usermod -a -G video ${USER_NAME} | ||
RUN <<EOT | ||
echo "# Configuring '${USER_NAME}' for X11 functionallity..." | ||
# | ||
# Assign audio group to non-root user | ||
usermod -a -G audio ${USER_NAME} | ||
# | ||
# Assign video group to non-root user | ||
usermod -a -G video ${USER_NAME} | ||
EOT | ||
|
||
# Install NVIDIA drivers in the image if NVIDIA_VERSION arg set | ||
RUN if [ ! -z ${NVIDIA_VERSION} ] ; then \ | ||
if [ "$TARGETARCH" = "arm64" ]; then TARGET=aarch64; elif [ "$TARGETARCH" = "amd64" ]; then TARGET=x86_64; else TARGET=$TARGETARCH; fi; \ | ||
echo "# Downloading NVIDIA drivers matching host version (${NVIDIA_VERSION})..."; \ | ||
curl -sSLO http://us.download.nvidia.com/XFree86/Linux-${TARGET}/${NVIDIA_VERSION}/NVIDIA-Linux-${TARGET}-${NVIDIA_VERSION}.run; \ | ||
chmod +x NVIDIA-Linux-${TARGET}-${NVIDIA_VERSION}.run; \ | ||
echo "# Installing NVIDIA drivers..."; \ | ||
./NVIDIA-Linux-${TARGET}-${NVIDIA_VERSION}.run --ui=none --no-kernel-module --no-install-compat32-libs --install-libglvnd --no-questions; \ | ||
rm NVIDIA-Linux-${TARGET}-${NVIDIA_VERSION}.run; \ | ||
RUN <<EOT | ||
if [ ! -z ${NVIDIA_VERSION} ] ; then | ||
if [ "$TARGETARCH" = "arm64" ]; then | ||
TARGET=aarch64 | ||
elif [ "$TARGETARCH" = "amd64" ]; then | ||
TARGET=x86_64 | ||
else | ||
TARGET=$TARGETARCH | ||
fi | ||
echo "# Downloading NVIDIA drivers matching host version (${NVIDIA_VERSION})..." | ||
curl -sSLO http://us.download.nvidia.com/XFree86/Linux-${TARGET}/${NVIDIA_VERSION}/NVIDIA-Linux-${TARGET}-${NVIDIA_VERSION}.run | ||
chmod +x NVIDIA-Linux-${TARGET}-${NVIDIA_VERSION}.run | ||
echo "# Installing NVIDIA drivers..." | ||
./NVIDIA-Linux-${TARGET}-${NVIDIA_VERSION}.run --ui=none --no-kernel-module --no-install-compat32-libs --install-libglvnd --no-questions | ||
rm NVIDIA-Linux-${TARGET}-${NVIDIA_VERSION}.run | ||
fi | ||
EOT | ||
|
||
# Add script to allow nvidia drivers installation on user interactive session | ||
ADD install-nvidia-drivers.sh /usr/bin/install-nvidia-drivers.sh | ||
RUN echo "# Configuring '${USER_NAME}' for NVIDIA drivers auto installation if NVIDIA_VERSION env variable is set..." \ | ||
# | ||
# Enable runtime nvidia drivers installation | ||
&& chmod +x /usr/bin/install-nvidia-drivers.sh \ | ||
# | ||
# Configure nvidia drivers installation for the non-root user | ||
&& printf "\n. /usr/bin/install-nvidia-drivers.sh\n" >> /home/${USER_NAME}/.bashrc | ||
RUN <<EOT | ||
echo "# Configuring '${USER_NAME}' for NVIDIA drivers auto installation if NVIDIA_VERSION env variable is set..." | ||
# | ||
# Enable runtime nvidia drivers installation | ||
chmod +x /usr/bin/install-nvidia-drivers.sh | ||
# | ||
# Configure nvidia drivers installation for the non-root user | ||
printf "\n. /usr/bin/install-nvidia-drivers.sh\n" >> /home/${USER_NAME}/.bashrc | ||
EOT | ||
|
||
# Clean up apt | ||
RUN apt-get autoremove -y \ | ||
&& apt-get clean -y \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
RUN <<EOT | ||
apt-get autoremove -y | ||
apt-get clean -y | ||
rm -rf /var/lib/apt/lists/* | ||
EOT | ||
|
||
# Switch back to dialog for any ad-hoc use of apt-get | ||
ENV DEBIAN_FRONTEND= | ||
|