Resolve KASM-2920 "Feature/ blender image"

This commit is contained in:
Bryan Scarbrough 2022-07-20 22:07:51 +00:00 committed by Justin Travis
parent 07ed1b0db7
commit 022f13b182
6 changed files with 177 additions and 2 deletions

View File

@ -39,6 +39,7 @@ variables:
.SINGLE_ARCH_BUILDS: &SINGLE_ARCH_BUILDS
- atom
- blender
- brave
- centos-7-desktop
- chrome
@ -132,7 +133,7 @@ build_app_images:
- aws-autoscale
parallel:
matrix:
- KASM_IMAGE: [doom, sublime-text, gimp, vs-code, teams, only-office, zoom, signal, steam, postman, insomnia, zsnes, vlc, maltego, telegram, hunchly, java-dev, terminal, vmware-horizon, remmina, rdesktop, discord, libre-office, thunderbird, atom, audacity, deluge, filezilla, inkscape, pinta, qbittorrent]
- KASM_IMAGE: [doom, sublime-text, gimp, vs-code, teams, only-office, zoom, signal, steam, postman, insomnia, zsnes, vlc, maltego, telegram, hunchly, java-dev, terminal, vmware-horizon, remmina, rdesktop, discord, libre-office, thunderbird, atom, audacity, deluge, filezilla, inkscape, pinta, qbittorrent, blender]
build_ubuntu_desktop_images:
stage: build
@ -429,7 +430,7 @@ build_schedules_app_images:
- aws-autoscale
parallel:
matrix:
- KASM_IMAGE: [doom, sublime-text, gimp, vs-code, teams, only-office, zoom, signal, steam, postman, insomnia, zsnes, vlc, maltego, telegram, hunchly, java-dev, terminal, vmware-horizon, remmina, rdesktop, discord, libre-office, thunderbird, atom, audacity, deluge, filezilla, inkscape, pinta, qbittorrent]
- KASM_IMAGE: [doom, sublime-text, gimp, vs-code, teams, only-office, zoom, signal, steam, postman, insomnia, zsnes, vlc, maltego, telegram, hunchly, java-dev, terminal, vmware-horizon, remmina, rdesktop, discord, libre-office, thunderbird, atom, audacity, deluge, filezilla, inkscape, pinta, qbittorrent, blender]
build_schedules_ubuntu_desktop_images:
image: ${ORG_NAME}/docker-buildx-private:develop
@ -528,6 +529,7 @@ update_readmes:
- KASM_IMAGE:
- atom
- audacity
- blender
- brave
- centos-7-desktop
- chrome

34
dockerfile-kasm-blender Normal file
View File

@ -0,0 +1,34 @@
ARG BASE_TAG="develop"
ARG BASE_IMAGE="core-ubuntu-focal"
FROM kasmweb/$BASE_IMAGE:$BASE_TAG
USER root
ENV HOME /home/kasm-default-profile
ENV STARTUPDIR /dockerstartup
ENV INST_SCRIPTS $STARTUPDIR/install
ENV NVIDIA_DRIVER_CAPABILITIES=graphics,compat32,utility,compute
WORKDIR $HOME
######### Customize Container Here ###########
COPY ./src/ubuntu/install/blender/install_blender.sh $INST_SCRIPTS/blender/
RUN bash $INST_SCRIPTS/blender/install_blender.sh && rm -rf $INST_SCRIPTS/blender/
COPY ./src/ubuntu/install/blender/custom_startup.sh $STARTUPDIR/custom_startup.sh
RUN chmod +x $STARTUPDIR/custom_startup.sh
RUN chmod 755 $STARTUPDIR/custom_startup.sh
# Update the desktop environment to be optimized for a single application
RUN cp $HOME/.config/xfce4/xfconf/single-application-xfce-perchannel-xml/* $HOME/.config/xfce4/xfconf/xfce-perchannel-xml/
RUN cp /usr/share/extra/backgrounds/bg_kasm.png /usr/share/extra/backgrounds/bg_default.png
RUN apt-get remove -y xfce4-panel
######### End Customizations ###########
RUN chown 1000:0 $HOME
ENV HOME /home/kasm-user
WORKDIR $HOME
RUN mkdir -p $HOME && chown -R 1000:0 $HOME
USER 1000

11
docs/blender/README.md Normal file
View File

@ -0,0 +1,11 @@
# About This Image
This Image contains a browser-accessible version of [Blender](https://www.blender.org/).
![Screenshot][Image_Screenshot]
[Image_Screenshot]: https://5856039.fs1.hubspotusercontent-na1.net/hubfs/5856039/dockerhub/image-screenshots/blender.png "Image Screenshot"
# Environment Variables
* `APP_ARGS` - Additional arguments to pass to the application when launched.

View File

@ -0,0 +1 @@
Blender for Kasm Workspaces

View File

@ -0,0 +1,84 @@
#!/usr/bin/env bash
set -ex
START_COMMAND="blender"
PGREP="blender"
export MAXIMIZE="true"
export MAXIMIZE_NAME="Blender"
MAXIMIZE_SCRIPT=$STARTUPDIR/maximize_window.sh
DEFAULT_ARGS=""
ARGS=${APP_ARGS:-$DEFAULT_ARGS}
options=$(getopt -o gau: -l go,assign,url: -n "$0" -- "$@") || exit
eval set -- "$options"
while [[ $1 != -- ]]; do
case $1 in
-g|--go) GO='true'; shift 1;;
-a|--assign) ASSIGN='true'; shift 1;;
-u|--url) OPT_URL=$2; shift 2;;
*) echo "bad option: $1" >&2; exit 1;;
esac
done
shift
# Process non-option arguments.
for arg; do
echo "arg! $arg"
done
FORCE=$2
kasm_exec() {
if [ -n "$OPT_URL" ] ; then
URL=$OPT_URL
elif [ -n "$1" ] ; then
URL=$1
fi
# Since we are execing into a container that already has the browser running from startup,
# when we don't have a URL to open we want to do nothing. Otherwise a second browser instance would open.
if [ -n "$URL" ] ; then
/usr/bin/filter_ready
/usr/bin/desktop_ready
bash ${MAXIMIZE_SCRIPT} &
$START_COMMAND $ARGS $OPT_URL
else
echo "No URL specified for exec command. Doing nothing."
fi
}
kasm_startup() {
if [ -n "$KASM_URL" ] ; then
URL=$KASM_URL
elif [ -z "$URL" ] ; then
URL=$LAUNCH_URL
fi
if [ -z "$DISABLE_CUSTOM_STARTUP" ] || [ -n "$FORCE" ] ; then
echo "Entering process startup loop"
set +x
while true
do
if ! pgrep -x $PGREP > /dev/null
then
/usr/bin/filter_ready
/usr/bin/desktop_ready
set +e
bash ${MAXIMIZE_SCRIPT} &
$START_COMMAND $ARGS $URL
set -e
fi
sleep 1
done
set -x
fi
}
if [ -n "$GO" ] || [ -n "$ASSIGN" ] ; then
kasm_exec
else
kasm_startup
fi

View File

@ -0,0 +1,43 @@
#!/usr/bin/env bash
set -ex
# If you require a specific version of Blender - rather than the latest - it can be
# hardcoded by setting this variable and rebuilding the container.
#BLENDER_VERSION="3.2.1"
apt-get update
apt-get install --no-install-recommends -y ocl-icd-libopencl1 \
xz-utils curl wget nano \
bzip2 libfreetype6 libgl1-mesa-dev \
libglu1-mesa \
libxi6 libxrender1
apt-get -y autoremove
ln -s libOpenCL.so.1 /usr/lib/x86_64-linux-gnu/libOpenCL.so
mkdir /blender
if [ -z ${BLENDER_VERSION+x} ]
then
BLENDER_VERSION=$(curl -sL https://mirror.clarkson.edu/blender/source/ \
| awk -F'"|/"' '/blender-[0-9]*\.[0-9]*\.[0-9]*\.tar\.xz/ && !/md5sum/ {print $2}' \
| tail -1 \
| sed 's|blender-||' \
| sed 's|\.tar\.xz||')
fi
BLENDER_FOLDER=$(echo "Blender${BLENDER_VERSION}" | sed -r 's|(Blender[0-9]*\.[0-9]*)\.[0-9]*|\1|')
curl -o /tmp/blender.tar.xz -L "https://mirror.clarkson.edu/blender/release/${BLENDER_FOLDER}/blender-${BLENDER_VERSION}-linux-x64.tar.xz"
tar xf /tmp/blender.tar.xz -C /blender/ --strip-components=1
cat >/usr/bin/blender <<EOF
#!/usr/bin/env bash
if [ -f /opt/VirtualGL/bin/vglrun ] && [ ! -z "\${KASM_EGL_CARD}" ] && [ ! -z "\${KASM_RENDERD}" ] && [ -O "\${KASM_RENDERD}" ] && [ -O "\${KASM_EGL_CARD}" ]
then
echo "Starting Blender with GPU Acceleration on EGL device \${KASM_EGL_CARD}"
vglrun -d "\${KASM_EGL_CARD}" /blender/blender "\$@"
else
echo "Starting Blender"
/blender/blender "\$@"
fi
EOF
chmod +x /usr/bin/blender
rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/*