2025-05-10 10:53:57 -04:00

391 lines
11 KiB
Docker

# syntax=docker/dockerfile:1
FROM node:12-buster AS wwwstage
ARG KASMWEB_RELEASE="46412d23aff1f45dffa83fafb04a683282c8db58"
RUN \
echo "**** build clientside ****" && \
export QT_QPA_PLATFORM=offscreen && \
export QT_QPA_FONTDIR=/usr/share/fonts && \
mkdir /src && \
cd /src && \
wget https://github.com/kasmtech/noVNC/tarball/${KASMWEB_RELEASE} -O - \
| tar --strip-components=1 -xz && \
npm install && \
npm run-script build
RUN \
echo "**** organize output ****" && \
mkdir /build-out && \
cd /src && \
rm -rf node_modules/ && \
cp -R ./* /build-out/ && \
cd /build-out && \
rm *.md && \
rm AUTHORS && \
cp index.html vnc.html && \
mkdir Downloads
FROM ghcr.io/linuxserver/baseimage-arch:latest AS buildstage
ARG KASMVNC_COMMIT="e04731870baebd2784983fb48197a2416c7d3519"
COPY --from=wwwstage /build-out /www
RUN \
echo "**** install build deps ****" && \
pacman -Sy --noconfirm \
autoconf \
automake \
base-devel \
cmake \
git \
kbd \
libdrm \
libepoxy \
libpciaccess \
libtool \
libwebp \
libx11 \
libxau \
libxcb \
libxcursor \
libxcvt \
libxdmcp \
libxext \
libxfont2 \
libxkbfile \
libxrandr \
libxshmfence \
libxtst \
mesa \
mesa-libgl \
meson \
patch \
pixman \
wget \
xcb-util \
xcb-util-image \
xcb-util-keysyms \
xcb-util-renderutil \
xcb-util-wm \
xkeyboard-config \
xorg-font-util \
xorgproto \
xorg-server \
xorg-util-macros \
xorg-xinit \
xorg-xkbcomp \
xtrans
RUN \
echo "**** build libjpeg-turbo ****" && \
mkdir /jpeg-turbo && \
JPEG_TURBO_RELEASE=$(curl -sX GET "https://api.github.com/repos/libjpeg-turbo/libjpeg-turbo/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
curl -o \
/tmp/jpeg-turbo.tar.gz -L \
"https://github.com/libjpeg-turbo/libjpeg-turbo/archive/${JPEG_TURBO_RELEASE}.tar.gz" && \
tar xf \
/tmp/jpeg-turbo.tar.gz -C \
/jpeg-turbo/ --strip-components=1 && \
cd /jpeg-turbo && \
MAKEFLAGS=-j`nproc` \
CFLAGS="-fpic" \
cmake -DCMAKE_INSTALL_PREFIX=/usr -G"Unix Makefiles" && \
make && \
make install
RUN \
echo "**** build kasmvnc ****" && \
git clone https://github.com/kasmtech/KasmVNC.git src && \
cd /src && \
git checkout -f ${KASMVNC_COMMIT} && \
sed -i \
-e '/find_package(FLTK/s@^@#@' \
-e '/add_subdirectory(tests/s@^@#@' \
-e 's/cmake_minimum_required(VERSION 2.8)/cmake_minimum_required(VERSION 3.10)/g' \
-e 's/CMP0022 OLD/CMP0022 NEW/g' \
CMakeLists.txt && \
cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DBUILD_VIEWER:BOOL=OFF \
-DENABLE_GNUTLS:BOOL=OFF \
. && \
make -j4 && \
echo "**** build xorg ****" && \
XORG_VER="21.1.14" && \
wget --no-check-certificate \
-O /tmp/xorg-server-${XORG_VER}.tar.gz \
"https://www.x.org/archive/individual/xserver/xorg-server-${XORG_VER}.tar.gz" && \
tar --strip-components=1 \
-C unix/xserver \
-xf /tmp/xorg-server-${XORG_VER}.tar.gz && \
cd unix/xserver && \
patch -Np1 -i ../xserver21.patch && \
patch -s -p0 < ../CVE-2022-2320-v1.20.patch && \
autoreconf -i && \
./configure --prefix=/opt/kasmweb \
--with-xkb-path=/usr/share/X11/xkb \
--with-xkb-output=/var/lib/xkb \
--with-xkb-bin-directory=/usr/bin \
--with-default-font-path="/usr/share/fonts/X11/misc,/usr/share/fonts/X11/cyrillic,/usr/share/fonts/X11/100dpi/:unscaled,/usr/share/fonts/X11/75dpi/:unscaled,/usr/share/fonts/X11/Type1,/usr/share/fonts/X11/100dpi,/usr/share/fonts/X11/75dpi,built-ins" \
--with-sha1=libcrypto \
--without-dtrace \
--disable-dri \
--disable-static \
--disable-xinerama \
--disable-xvfb \
--disable-xnest \
--disable-xorg \
--disable-dmx \
--disable-xwin \
--disable-xephyr \
--disable-kdrive \
--disable-config-hal \
--disable-config-udev \
--disable-dri2 \
--enable-glx \
--disable-xwayland \
--enable-dri3 && \
find . -name "Makefile" -exec sed -i 's/-Werror=array-bounds//g' {} \; && \
make -j4
RUN \
echo "**** generate final output ****" && \
cd /src && \
mkdir -p xorg.build/bin && \
cd xorg.build/bin/ && \
ln -s /src/unix/xserver/hw/vnc/Xvnc Xvnc && \
cd .. && \
mkdir -p man/man1 && \
touch man/man1/Xserver.1 && \
cp /src/unix/xserver/hw/vnc/Xvnc.man man/man1/Xvnc.1 && \
mkdir lib && \
cd lib && \
ln -s /usr/lib64/dri dri && \
cd /src && \
mkdir -p builder/www && \
cp -ax /www/* builder/www/ && \
cp builder/www/index.html builder/www/vnc.html && \
make servertarball && \
mkdir /build-out && \
tar xzf \
kasmvnc-Linux*.tar.gz \
-C /build-out/ && \
rm -Rf /build-out/usr/local/share/man
# nodejs builder
FROM ghcr.io/linuxserver/baseimage-arch:latest AS nodebuilder
ARG KCLIENT_RELEASE
RUN \
echo "**** install build deps ****" && \
pacman -Syu --noconfirm \
base-devel \
curl \
libpulse \
nodejs \
npm \
python3
RUN \
echo "**** grab source ****" && \
mkdir -p /kclient && \
if [ -z ${KCLIENT_RELEASE+x} ]; then \
KCLIENT_RELEASE=$(curl -sX GET "https://api.github.com/repos/linuxserver/kclient/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
fi && \
curl -o \
/tmp/kclient.tar.gz -L \
"https://github.com/linuxserver/kclient/archive/${KCLIENT_RELEASE}.tar.gz" && \
tar xf \
/tmp/kclient.tar.gz -C \
/kclient/ --strip-components=1
RUN \
echo "**** install node modules ****" && \
cd /kclient && \
npm install && \
rm -f package-lock.json
# runtime stage
FROM ghcr.io/linuxserver/baseimage-arch:latest
# set version label
ARG BUILD_DATE
ARG VERSION
ARG KASMBINS_RELEASE="1.15.0"
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="thelamer"
LABEL "com.kasmweb.image"="true"
# env
ENV DISPLAY=:1 \
PERL5LIB=/usr/local/bin \
OMP_WAIT_POLICY=PASSIVE \
GOMP_SPINCOUNT=0 \
HOME=/config \
START_DOCKER=true \
PULSE_RUNTIME_PATH=/defaults \
NVIDIA_DRIVER_CAPABILITIES=all
# copy over build output
COPY --from=nodebuilder /kclient /kclient
COPY --from=buildstage /build-out/ /
RUN \
echo "**** enable locales ****" && \
sed -i \
'/locale/d' \
/etc/pacman.conf && \
echo "**** install deps ****" && \
pacman -Sy --noconfirm --needed \
amdvlk \
base-devel \
cups \
cups-pdf \
docker \
docker-compose \
dunst \
ffmpeg \
fuse-overlayfs \
git \
inetutils \
intel-media-driver \
kbd \
libjpeg-turbo \
libnotify \
libva-mesa-driver \
libwebp \
libxfont2 \
libxshmfence \
libva-mesa-driver \
mesa \
mesa-libgl \
nginx \
nodejs \
noto-fonts \
noto-fonts-emoji \
openbox \
openssh \
pciutils \
perl-datetime \
perl-list-moreutils \
perl-switch \
perl-try-tiny \
perl-yaml-tiny \
pixman \
pulseaudio \
python3 \
python-pyxdg \
sudo \
vulkan-extra-layers \
vulkan-intel \
vulkan-radeon \
vulkan-swrast \
vulkan-tools \
xdg-utils \
xf86-video-amdgpu \
xf86-video-ati \
xf86-video-intel \
xf86-video-nouveau \
xf86-video-qxl \
xkeyboard-config \
xorg-setxkbmap \
xorg-xauth \
xorg-xkbcomp \
xterm && \
pacman -Sy --noconfirm \
glibc && \
echo "**** printer config ****" && \
sed -i \
"s:^#Out.*:Out /home/kasm-user/PDF:" \
/etc/cups/cups-pdf.conf && \
echo "**** user perms ****" && \
useradd \
-u 1000 -U \
-d /home/kasm-user \
-s /bin/bash kasm-user && \
usermod -G users kasm-user && \
echo "kasm-user:kasm" | chpasswd && \
mkdir -p /home/kasm-user && \
chown 1000:1000 /home/kasm-user && \
mkdir -p /var/run/pulse && \
chown 1000:root /var/run/pulse && \
echo "abc:abc" | chpasswd && \
usermod -s /bin/bash abc && \
echo 'abc ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/abc && \
echo 'kasm-user ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/kasm-user && \
echo "allowed_users=anybody" > /etc/X11/Xwrapper.config && \
echo "**** build perl-hash-merge-simple ****" && \
cd /tmp && \
git clone https://aur.archlinux.org/perl-hash-merge-simple.git && \
chown -R abc:abc perl-hash-merge-simple && \
cd perl-hash-merge-simple && \
sudo -u abc makepkg -sAci --skipinteg --noconfirm --needed && \
echo "**** filesystem setup ****" && \
ln -s /usr/local/share/kasmvnc /usr/share/kasmvnc && \
ln -s /usr/local/etc/kasmvnc /etc/kasmvnc && \
ln -s /usr/local/lib/kasmvnc /usr/lib/kasmvncserver && \
echo "**** openbox tweaks ****" && \
sed -i \
-e 's/NLIMC/NLMC/g' \
-e 's|</applications>| <application class="*"><maximized>yes</maximized></application>\n</applications>|' \
-e 's|</keyboard>| <keybind key="C-S-d"><action name="ToggleDecorations"/></keybind>\n</keyboard>|' \
/etc/xdg/openbox/rc.xml && \
echo "**** proot-apps ****" && \
mkdir /proot-apps/ && \
PAPPS_RELEASE=$(curl -sX GET "https://api.github.com/repos/linuxserver/proot-apps/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]') && \
curl -L https://github.com/linuxserver/proot-apps/releases/download/${PAPPS_RELEASE}/proot-apps-x86_64.tar.gz \
| tar -xzf - -C /proot-apps/ && \
echo "${PAPPS_RELEASE}" > /proot-apps/pversion && \
echo "**** kasm support ****" && \
mkdir -p /kasmbins && \
curl -s https://kasm-ci.s3.amazonaws.com/kasmbins-amd64-${KASMBINS_RELEASE}.tar.gz \
| tar xzvf - -C /kasmbins/ && \
chmod +x /kasmbins/* && \
chown -R 1000:1000 /kasmbins && \
chown 1000:1000 /usr/share/kasmvnc/www/Downloads && \
mkdir -p /dockerstartup && \
mv \
/usr/sbin/notify-send \
/usr/sbin/notify-send-real && \
echo "**** dind support ****" && \
groupadd -r dockremap && \
useradd -r -g dockremap dockremap && \
echo 'dockremap:165536:65536' >> /etc/subuid && \
echo 'dockremap:165536:65536' >> /etc/subgid && \
curl -o \
/usr/local/bin/dind -L \
https://raw.githubusercontent.com/moby/moby/master/hack/dind && \
chmod +x /usr/local/bin/dind && \
usermod -aG docker abc && \
echo "**** configure locale and nginx ****" && \
for LOCALE in $(curl -sL https://raw.githubusercontent.com/thelamer/lang-stash/master/langs); do \
localedef -i $LOCALE -f UTF-8 $LOCALE.UTF-8; \
done && \
sed -i '$d' /etc/nginx/nginx.conf && \
echo "include /etc/nginx/conf.d/*;}" >> /etc/nginx/nginx.conf && \
mkdir -p /etc/nginx/conf.d && \
echo "**** theme ****" && \
curl -s https://raw.githubusercontent.com/thelamer/lang-stash/master/theme.tar.gz \
| tar xzvf - -C /usr/share/themes/Clearlooks/openbox-3/ && \
echo "**** cleanup ****" && \
pacman -Rsn --noconfirm \
git \
$(pacman -Qdtq) && \
rm -rf \
/tmp/* \
/var/cache/pacman/pkg/* \
/var/lib/pacman/sync/*
# add local files
COPY /root /
# ports and volumes
EXPOSE 3000 3001
VOLUME /config