Merge branch 'feature/KASM-1973_virgualgl' into 'develop'

Resolve KASM-1973 "Feature/ virgualgl"

Closes KASM-1973

See merge request kasm-technologies/internal/workspaces-core-images!32
This commit is contained in:
Matthew McClaskey 2021-12-15 17:25:15 +00:00
commit ef2669d4fc
12 changed files with 283 additions and 12 deletions

View File

@ -49,6 +49,20 @@ build_cuda_bionic:
except: except:
- schedules - schedules
build_nvidia_focal:
stage: build
script:
- docker build -t ${ORG_NAME}/core-nvidia-focal-private:$SANITIZED_BRANCH -t ${ORG_NAME}/core-nvidia-focal-private:$SANITIZED_ROLLING_BRANCH -t ${ORG_NAME}/core-nvidia-focal:$SANITIZED_BRANCH -t ${ORG_NAME}/core-nvidia-focal:$SANITIZED_ROLLING_BRANCH --build-arg BASE_IMAGE=ubuntu:20.04"" --build-arg BG_IMG=bg_bionic.png -f dockerfile-kasm-core-nvidia .
- docker push ${ORG_NAME}/core-nvidia-focal-private:$SANITIZED_BRANCH
- docker push ${ORG_NAME}/core-nvidia-focal-private:$SANITIZED_ROLLING_BRANCH
- docker push ${ORG_NAME}/core-nvidia-focal:$SANITIZED_BRANCH
- docker push ${ORG_NAME}/core-nvidia-focal:$SANITIZED_ROLLING_BRANCH
only:
- develop
- /^release\/.*$/
except:
- schedules
build_remnux_bionic: build_remnux_bionic:
stage: build stage: build
script: script:
@ -123,6 +137,15 @@ build_cuda_bionic_dev:
- develop - develop
- /^release\/.*$/ - /^release\/.*$/
build_nvidia_focal_dev:
stage: build
script:
- docker build -t ${ORG_NAME}/core-nvidia-focal-private:$SANITIZED_BRANCH --build-arg BASE_IMAGE="ubuntu:20.04" --build-arg BG_IMG=bg_bionic.png -f dockerfile-kasm-core-nvidia .
- docker push ${ORG_NAME}/core-nvidia-focal-private:$SANITIZED_BRANCH
except:
- develop
- /^release\/.*$/
build_remnux_bionic_dev: build_remnux_bionic_dev:
stage: build stage: build
script: script:
@ -179,6 +202,15 @@ build_cuda_bionic_schedules:
only: only:
- schedules - schedules
build_nvidia_focal_schedules:
stage: build
script:
- docker build -t ${ORG_NAME}/core-nvidia-focal-private:$SANITIZED_ROLLING_BRANCH -t ${ORG_NAME}/core-nvidia-focal:$SANITIZED_ROLLING_BRANCH --build-arg BASE_IMAGE="ubuntu:20.04" --build-arg BG_IMG=bg_bionic.png -f dockerfile-kasm-core-nvidia .
- docker push ${ORG_NAME}/core-nvidia-focal-private:$SANITIZED_ROLLING_BRANCH
- docker push ${ORG_NAME}/core-nvidia-focal:$SANITIZED_ROLLING_BRANCH
only:
- schedules
build_remnux_bionic_schedules: build_remnux_bionic_schedules:
stage: build stage: build
script: script:
@ -225,4 +257,4 @@ update_readmes:
- $README_PASSWORD - $README_PASSWORD
parallel: parallel:
matrix: matrix:
- KASM_IMAGE: [core-centos-7, core-kali-rolling, core-remnux-bionic, core-cuda-bionic, core-ubuntu-bionic] - KASM_IMAGE: [core-centos-7, core-kali-rolling, core-remnux-bionic, core-cuda-bionic, core-ubuntu-bionic, core-nvidia-focal]

185
dockerfile-kasm-core-nvidia Normal file
View File

@ -0,0 +1,185 @@
ARG BASE_IMAGE="ubuntu:focal"
FROM $BASE_IMAGE AS install_tools
### Install common tools
COPY ./src/ubuntu/install/tools $INST_SCRIPTS/tools/
RUN bash $INST_SCRIPTS/tools/install_tools.sh && rm -rf $INST_SCRIPTS/tools/
FROM install_tools AS squid_builder
### Build Squid
RUN wget 'https://kasmweb-build-artifacts.s3.amazonaws.com/kasm-squid-builder/a590f319f328a8a576cb966c2db5ec4a5b3b7b9b/output/kasm-squid-builder_ubuntu.tar.gz'
RUN tar -xzf kasm-squid-builder_ubuntu.tar.gz -C /
FROM install_tools
MAINTAINER Kasm Tech "info@kasmweb.com"
LABEL "com.kasmweb.image"="true"
LABEL "com.kasmweb.gpu_acceleration_egl"="nvidia"
### Environment config
ARG START_XFCE4=1
ARG START_PULSEAUDIO=0
ARG BG_IMG=bg_kasm.png
ARG EXTRA_SH=noop.sh
ARG DISTRO=ubuntu
ARG LANG='en_US.UTF-8'
ARG LANGUAGE='en_US:en'
ARG LC_ALL='en_US.UTF-8'
ENV DISPLAY=:1 \
VNC_PORT=5901 \
NO_VNC_PORT=6901 \
VNC_PORT=5901 \
AUDIO_PORT=4901 \
VNC_RESOLUTION=1280x720 \
MAX_FRAME_RATE=24 \
VNCOPTIONS="-PreferBandwidth -DynamicQualityMin=4 -DynamicQualityMax=7 -DLP_ClipDelay=0" \
HOME=/home/kasm-default-profile \
TERM=xterm \
STARTUPDIR=/dockerstartup \
INST_SCRIPTS=/dockerstartup/install \
KASM_VNC_PATH=/usr/share/kasmvnc \
DEBIAN_FRONTEND=noninteractive \
VNC_COL_DEPTH=24 \
VNC_RESOLUTION=1280x1024 \
VNC_PW=vncpassword \
VNC_VIEW_ONLY_PW=vncviewonlypassword \
LD_LIBRARY_PATH=/usr/local/lib/ \
OMP_WAIT_POLICY=PASSIVE \
SHELL=/bin/bash \
START_XFCE4=$START_XFCE4 \
START_PULSEAUDIO=$START_PULSEAUDIO \
LANG=$LANG \
LANGUAGE=$LANGUAGE \
LC_ALL=$LC_ALL
EXPOSE $VNC_PORT \
$NO_VNC_PORT \
$UPLOAD_PORT \
$AUDIO_PORT
WORKDIR $HOME
RUN mkdir -p $HOME/Desktop
# NVIDIA SETUP
RUN echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf
ENV LD_LIBRARY_PATH /usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
ENV NVIDIA_DRIVER_CAPABILITIES=${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics,compat32,utility
RUN dpkg --add-architecture i386 && \
apt-get update && apt-get install -y --no-install-recommends \
libxau6 libxau6:i386 \
libxdmcp6 libxdmcp6:i386 \
libxcb1 libxcb1:i386 \
libxext6 libxext6:i386 \
libx11-6 libx11-6:i386
RUN apt-get update && apt-get install -y --no-install-recommends \
libglvnd0 libglvnd0:i386 \
libgl1 libgl1:i386 \
libglx0 libglx0:i386 \
libegl1 libegl1:i386 \
libgles2 libgles2:i386
COPY src/ubuntu/install/nvidia/10_nvidia.json /usr/share/glvnd/egl_vendor.d/10_nvidia.json
### Install custom fonts
COPY ./src/ubuntu/install/fonts $INST_SCRIPTS/fonts/
RUN bash $INST_SCRIPTS/fonts/install_custom_fonts.sh && rm -rf $INST_SCRIPTS/fonts/
### Install xfce UI
COPY ./src/ubuntu/install/xfce $INST_SCRIPTS/xfce/
RUN bash $INST_SCRIPTS/xfce/install_xfce_ui.sh && rm -rf $INST_SCRIPTS/xfce/
ADD ./src/$DISTRO/xfce/.config/ $HOME/.config/
RUN mkdir -p /usr/share/extra/backgrounds/
RUN mkdir -p /usr/share/extra/icons/
ADD /src/common/resources/images/bg_kasm.png /usr/share/extra/backgrounds/bg_kasm.png
ADD /src/common/resources/images/$BG_IMG /usr/share/extra/backgrounds/bg_default.png
ADD /src/common/resources/images/icon_ubuntu.png /usr/share/extra/icons/icon_ubuntu.png
ADD /src/common/resources/images/icon_ubuntu.png /usr/share/extra/icons/icon_default.png
ADD /src/common/resources/images/icon_kasm.png /usr/share/extra/icons/icon_kasm.png
ADD ./src/common/xfce/window_manager_startup.sh $STARTUPDIR
### Install kasm_vnc dependencies and binaries
COPY ./src/ubuntu/install/kasm_vnc $INST_SCRIPTS/kasm_vnc/
RUN bash $INST_SCRIPTS/kasm_vnc/install_kasm_vnc.sh && rm -rf $INST_SCRIPTS/kasm_vnc/
### Install Kasm Upload Server
COPY ./src/ubuntu/install/kasm_upload_server $INST_SCRIPTS/kasm_upload_server/
RUN bash $INST_SCRIPTS/kasm_upload_server/install_kasm_upload_server.sh && rm -rf $INST_SCRIPTS/kasm_upload_server/
### Install Audio
COPY ./src/ubuntu/install/audio $INST_SCRIPTS/audio/
RUN bash $INST_SCRIPTS/audio/install_audio.sh && rm -rf $INST_SCRIPTS/audio/
### Install Audio Input
COPY ./src/ubuntu/install/audio_input $INST_SCRIPTS/audio_input/
RUN bash $INST_SCRIPTS/audio_input/install_audio_input.sh && rm -rf $INST_SCRIPTS/audio_input/
### Install custom cursors
COPY ./src/ubuntu/install/cursors $INST_SCRIPTS/cursors/
RUN bash $INST_SCRIPTS/cursors/install_cursors.sh && rm -rf $INST_SCRIPTS/cursors/
### Copy built Squid
COPY --from=squid_builder /usr/local/squid /usr/local/squid
### Install Squid
COPY ./src/ubuntu/install/squid/install/ $INST_SCRIPTS/squid_install/
RUN bash $INST_SCRIPTS/squid_install/install_squid.sh && rm -rf $INST_SCRIPTS/squid_install/
COPY ./src/ubuntu/install/squid/resources/*.conf /etc/squid/
COPY ./src/ubuntu/install/squid/resources/start_squid.sh /etc/squid/start_squid.sh
COPY ./src/ubuntu/install/squid/resources/SN.png /usr/local/squid/share/icons/SN.png
RUN chown proxy:proxy /usr/local/squid/share/icons/SN.png
COPY ./src/ubuntu/install/squid/resources/error_message/access_denied.html /usr/local/squid/share/errors/en/ERR_ACCESS_DENIED
RUN chown proxy:proxy /usr/local/squid/share/errors/en/ERR_ACCESS_DENIED
RUN rm -rf $INST_SCRIPTS/resources/
RUN chmod +x /etc/squid/kasm_squid_adapter
RUN chmod +x /etc/squid/start_squid.sh && chmod 4755 /etc/squid/start_squid.sh
### configure startup
COPY ./src/common/scripts/kasm_hook_scripts $STARTUPDIR
ADD ./src/common/startup_scripts $STARTUPDIR
RUN bash $STARTUPDIR/set_user_permission.sh $STARTUPDIR $HOME
### extra configurations needed per distro variant
COPY ./src/ubuntu/install/extra $INST_SCRIPTS/extra/
RUN bash $INST_SCRIPTS/extra/$EXTRA_SH && rm -rf $INST_SCRIPTS/extra/
### VirtualGL
COPY ./src/ubuntu/install/virtualgl $INST_SCRIPTS/virtualgl/
RUN bash $INST_SCRIPTS/virtualgl/install_virtualgl.sh && rm -rf $INST_SCRIPTS/virtualgl/
RUN groupadd -g 1000 ubuntu \
&& useradd -u 1000 -g 1000 -m ubuntu \
&& usermod -a -G ubuntu ubuntu
ENV HOME /home/kasm-user
WORKDIR $HOME
RUN mkdir -p $HOME && chown -R 1000:0 $HOME
### FIX PERMISSIONS ## Objective is to change the owner of non-home paths to root, remove write permissions, and set execute where required
# these files are created on container first exec, by the default user, so we have to create them since default will not have write perm
RUN touch $STARTUPDIR/wm.log \
&& touch $STARTUPDIR/window_manager_startup.log \
&& touch $STARTUPDIR/vnc_startup.log \
&& touch $STARTUPDIR/no_vnc_startup.log \
&& chown -R root:root $STARTUPDIR \
&& find $STARTUPDIR -type d -exec chmod 755 {} \; \
&& find $STARTUPDIR -type f -exec chmod 644 {} \; \
&& find $STARTUPDIR -type f -iname "*.sh" -exec chmod 755 {} \; \
&& find $STARTUPDIR -type f -iname "*.py" -exec chmod 755 {} \; \
&& find $STARTUPDIR -type f -iname "*.rb" -exec chmod 755 {} \; \
&& find $STARTUPDIR -type f -iname "*.pl" -exec chmod 755 {} \; \
&& find $STARTUPDIR -type f -iname "*.log" -exec chmod 666 {} \; \
&& chmod 755 $STARTUPDIR/upload_server/kasm_upload_server \
&& chmod 755 $STARTUPDIR/audio_input/kasm_audio_input_server \
&& chmod 755 $STARTUPDIR/generate_container_user \
&& chmod +x $STARTUPDIR/jsmpeg/kasm_audio_out-linux \
&& rm -rf $STARTUPDIR/install \
&& mkdir -p $STARTUPDIR/kasmrx/Downloads \
&& chown 1000:1000 $STARTUPDIR/kasmrx/Downloads \
&& chown -R root:root /usr/local/bin
USER ubuntu
ENTRYPOINT ["/dockerstartup/kasm_default_profile.sh", "/dockerstartup/vnc_startup.sh", "/dockerstartup/kasm_startup.sh"]
CMD ["--wait"]

View File

@ -0,0 +1,7 @@
# About This Image
This image contains a browser-accessible version of Ubuntu Focal Desktop with GPU Acceleration. Requires a compatible Nvidia
![Screenshot][Image_Screenshot]
[Image_Screenshot]: https://f.hubspotusercontent30.net/hubfs/5856039/dockerhub/image-screenshots/core-cuda-bionic.png "Image Screenshot"

View File

@ -0,0 +1 @@
Base image for Kasm Workspaces with 3D GPU Acceleration for compatible Nvidia based GPUs.

View File

@ -147,7 +147,9 @@ if [[ $1 =~ -h|--help ]]; then
fi fi
# should also source $STARTUPDIR/generate_container_user # should also source $STARTUPDIR/generate_container_user
source $HOME/.bashrc if [ -f $HOME/.bashrc ]; then
source $HOME/.bashrc
fi
if [[ ${KASM_DEBUG:-0} == 1 ]]; then if [[ ${KASM_DEBUG:-0} == 1 ]]; then
echo -e "\n\n------------------ DEBUG KASM STARTUP -----------------" echo -e "\n\n------------------ DEBUG KASM STARTUP -----------------"

View File

@ -5,8 +5,13 @@ echo -e "\n------------------ Xfce4 window manager startup------------------"
if [ "${START_XFCE4}" == "1" ] ; if [ "${START_XFCE4}" == "1" ] ;
then then
echo "Starting XFCE" if [ -f /usr/bin/vglrun ] && [ -d /dev/dri ] && [ -O /dev/dri/card0 ] && [ -O /dev/dri/renderD128 ] ; then
/usr/bin/startxfce4 --replace & echo "Starting XFCE with VirtualGL"
DISPLAY=:1 /usr/bin/vglrun -d /dev/dri/card0 /usr/bin/startxfce4 --replace &
else
echo "Starting XFCE"
/usr/bin/startxfce4 --replace &
fi
else else
echo "Skipping XFCE Startup" echo "Skipping XFCE Startup"
fi fi

View File

@ -4,7 +4,7 @@ set -e
install_libjpeg_turbo() { install_libjpeg_turbo() {
local libjpeg_deb=libjpeg-turbo.deb local libjpeg_deb=libjpeg-turbo.deb
wget 'https://kasmweb-build-artifacts.s3.amazonaws.com/kasmvnc/dc4e4ce3487a1eefe0df1c86bc44d3308ca211b7/output/bionic/libjpeg-turbo_2.1.2_amd64.deb' -O "$libjpeg_deb" wget "https://kasmweb-build-artifacts.s3.amazonaws.com/kasmvnc/${COMMIT_ID}/output/${UBUNTU_CODENAME}/libjpeg-turbo_2.1.3_amd64.deb" -O "$libjpeg_deb"
apt-get install -y "./$libjpeg_deb" apt-get install -y "./$libjpeg_deb"
rm "$libjpeg_deb" rm "$libjpeg_deb"
} }
@ -13,17 +13,24 @@ echo "Install KasmVNC server"
cd /tmp cd /tmp
BUILD_ARCH=$(uname -p) BUILD_ARCH=$(uname -p)
UBUNTU_CODENAME=""
COMMIT_ID="ca7949537a911ef8e795d2d65583c61c4a00cae7"
BRANCH="master"
COMMIT_ID_SHORT=$(echo "${COMMIT_ID}" | cut -c1-6)
if [ "${DISTRO}" == "kali" ] ; if [ "${DISTRO}" == "kali" ] ;
then then
BUILD_URL="https://kasmweb-build-artifacts.s3.amazonaws.com/kasmvnc/dc4e4ce3487a1eefe0df1c86bc44d3308ca211b7/kasmvncserver_kali-rolling_0.9.3_master_dc4e4c_amd64.deb" BUILD_URL="https://kasmweb-build-artifacts.s3.amazonaws.com/kasmvnc/${COMMIT_ID}/kasmvncserver_kali-rolling_0.9.3_${BRANCH}_${COMMIT_ID_SHORT}_amd64.deb"
elif [ "${DISTRO}" == "centos" ] ; then elif [ "${DISTRO}" == "centos" ] ; then
BUILD_URL="https://kasmweb-build-artifacts.s3.amazonaws.com/kasmvnc/dc4e4ce3487a1eefe0df1c86bc44d3308ca211b7/output/centos_core/kasmvncserver-0.9.1~beta-1.el7.x86_64.rpm" BUILD_URL="https://kasmweb-build-artifacts.s3.amazonaws.com/kasmvnc/${COMMIT_ID}/output/centos_core/kasmvncserver-0.9.1~beta-1.el7.x86_64.rpm"
else else
UBUNTU_CODENAME=$(grep -Po -m 1 "(?<=_CODENAME=)\w+" /etc/os-release)
if [[ "${BUILD_ARCH}" =~ ^aarch64$ ]] ; then if [[ "${BUILD_ARCH}" =~ ^aarch64$ ]] ; then
BUILD_URL="https://kasmweb-build-artifacts.s3.amazonaws.com/kasmvnc/dc4e4ce3487a1eefe0df1c86bc44d3308ca211b7/kasmvncserver_bionic_0.9.3_master_dc4e4c_arm64.deb" BUILD_URL="https://kasmweb-build-artifacts.s3.amazonaws.com/kasmvnc/${COMMIT_ID}/kasmvncserver_${UBUNTU_CODENAME}_0.9.3_${BRANCH}_${COMMIT_ID_SHORT}_arm64.deb"
elif [ "${UBUNTU_CODENAME}" == "bionic" ] ; then
BUILD_URL="https://kasmweb-build-artifacts.s3.amazonaws.com/kasmvnc/${COMMIT_ID}/kasmvncserver_${UBUNTU_CODENAME}_0.9.3_${BRANCH}_${COMMIT_ID_SHORT}_libjpeg-turbo-latest_amd64.deb"
else else
BUILD_URL="https://kasmweb-build-artifacts.s3.amazonaws.com/kasmvnc/dc4e4ce3487a1eefe0df1c86bc44d3308ca211b7/kasmvncserver_bionic_0.9.3_master_dc4e4c_libjpeg-turbo-latest_amd64.deb" BUILD_URL="https://kasmweb-build-artifacts.s3.amazonaws.com/kasmvnc/${COMMIT_ID}/kasmvncserver_${UBUNTU_CODENAME}_0.9.3_${BRANCH}_${COMMIT_ID_SHORT}_amd64.deb"
fi fi
fi fi
@ -34,7 +41,7 @@ if [ "${DISTRO}" == "centos" ] ; then
yum localinstall -y kasmvncserver.rpm yum localinstall -y kasmvncserver.rpm
rm kasmvncserver.rpm rm kasmvncserver.rpm
else else
if [[ "$DISTRO" = "ubuntu" ]] && [[ ! "$BUILD_ARCH" =~ ^aarch64$ ]] ; then if [[ "${UBUNTU_CODENAME}" = "bionic" ]] && [[ ! "$BUILD_ARCH" =~ ^aarch64$ ]] ; then
install_libjpeg_turbo install_libjpeg_turbo
fi fi

View File

@ -0,0 +1,7 @@
{
"file_format_version" : "1.0.0",
"ICD" : {
"library_path" : "libEGL_nvidia.so.0"
}
}

View File

@ -9,7 +9,7 @@ if [ "${DISTRO}" == "centos" ] ; then
rm wmctrl*.rpm rm wmctrl*.rpm
else else
apt-get update apt-get update
apt-get install -y vim wget net-tools locales bzip2 wmctrl software-properties-common apt-get install -y vim wget net-tools locales bzip2 wmctrl software-properties-common mesa-utils
apt-get clean -y apt-get clean -y
echo "generate locales für en_US.UTF-8" echo "generate locales für en_US.UTF-8"

View File

@ -0,0 +1,13 @@
if [ "$DISTRO" = "ubuntu" ]; then
#update mesa to latest
add-apt-repository ppa:kisak/kisak-mesa
apt full-upgrade -y
#install virtualgl
#wget https://sourceforge.net/projects/virtualgl/files/2.6.95%20%283.0rc1%29/virtualgl_2.6.95_amd64.deb -P /tmp
set +e
dpkg -i $INST_SCRIPTS/virtualgl/virtualgl_*amd64.deb
set -e
apt install -f -y
rm $INST_SCRIPTS/virtualgl/virtualgl_*amd64.deb
fi

View File

@ -40,6 +40,15 @@ EOL
chmod +x /etc/X11/xinit/xinitrc chmod +x /etc/X11/xinit/xinitrc
} }
replace_default_99x11_common_start() {
if [ -f /etc/X11/Xsession.d/99x11-common_start ] ; then
cat >/etc/X11/Xsession.d/99x11-common_start <<EOL
# This file is sourced by Xsession(5), not executed.
# exec $STARTUP
EOL
fi
}
echo "Install Xfce4 UI components" echo "Install Xfce4 UI components"
if [ "$DISTRO" != "centos" ]; then if [ "$DISTRO" != "centos" ]; then
apt-get update apt-get update
@ -75,6 +84,9 @@ if [ "$DISTRO" = "centos" ]; then
else else
replace_default_xinit replace_default_xinit
config_xinit_disable_screensaver config_xinit_disable_screensaver
if [ "${START_XFCE4}" == "1" ] ; then
replace_default_99x11_common_start
fi
fi fi
# Override default login script so users cant log themselves out of the desktop dession # Override default login script so users cant log themselves out of the desktop dession
@ -106,4 +118,4 @@ cat >>/etc/xdg/Thunar/accels.scm<<EOL
(gtk_accel_path "<Actions>/ThunarLauncher/delete" "Delete") (gtk_accel_path "<Actions>/ThunarLauncher/delete" "Delete")
(gtk_accel_path "<Actions>/ThunarLauncher/trash-delete-2" "") (gtk_accel_path "<Actions>/ThunarLauncher/trash-delete-2" "")
(gtk_accel_path "<Actions>/ThunarLauncher/trash-delete" "") (gtk_accel_path "<Actions>/ThunarLauncher/trash-delete" "")
EOL EOL