Merge branch 'KASM-7194-modify-build-scripts-and-docker-image-for-faster-rebuilds-during-development' into 'master'

KASM-7194 Modify build scripts and docker image for faster rebuilds during development

Closes KASM-7194

See merge request kasm-technologies/internal/KasmVNC!170
This commit is contained in:
Matthew McClaskey 2025-04-22 11:47:53 +00:00
commit 3cc739adb3
22 changed files with 143 additions and 93 deletions

View File

@ -91,7 +91,7 @@ npm run build # <-- only run this on subsequent changes to front-end code
cd .. cd ..
# build dependencies # build dependencies
sudo builder/scripts/build-webp sudo builder/scripts/build-webp
sudo builder/scripts/build-build-libjpeg-turbo sudo builder/scripts/build-libjpeg-turbo
# Build KasmVNC # Build KasmVNC
builder/build.sh builder/build.sh
``` ```

View File

@ -242,8 +242,9 @@ if(ENABLE_NLS)
add_subdirectory(po) add_subdirectory(po)
endif() endif()
####add_subdirectory(tests) if (TESTS)
add_subdirectory(tests)
endif ()
include(cmake/BuildPackages.cmake) include(cmake/BuildPackages.cmake)

View File

@ -44,29 +44,29 @@ if [[ "${XORG_VER}" == 21* ]]; then
else else
XORG_PATCH=$(echo "$XORG_VER" | grep -Po '^\d.\d+' | sed 's#\.##') XORG_PATCH=$(echo "$XORG_VER" | grep -Po '^\d.\d+' | sed 's#\.##')
fi fi
wget --no-check-certificate https://www.x.org/archive/individual/xserver/xorg-server-${XORG_VER}.tar.gz
TARBALL="xorg-server-${XORG_VER}.tar.gz"
if [ ! -f "$TARBALL" ]; then
wget --no-check-certificate https://www.x.org/archive/individual/xserver/"$TARBALL"
fi
#git clone https://kasmweb@bitbucket.org/kasmtech/kasmvnc.git #git clone https://kasmweb@bitbucket.org/kasmtech/kasmvnc.git
#cd kasmvnc #cd kasmvnc
#git checkout dynjpeg #git checkout dynjpeg
cd /src cd /src
# We only want the server, so FLTK and manual tests aren't useful.
# Alternatively, install fltk 1.3 and its dev packages.
sed -i -e '/find_package(FLTK/s@^@#@' \
-e '/add_subdirectory(tests/s@^@#@' \
CMakeLists.txt
cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo . -DBUILD_VIEWER:BOOL=OFF \ cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo . -DBUILD_VIEWER:BOOL=OFF \
-DENABLE_GNUTLS:BOOL=OFF -DENABLE_GNUTLS:BOOL=OFF
make -j5 make -j"$(nproc)"
tar -C unix/xserver -xf /tmp/xorg-server-${XORG_VER}.tar.gz --strip-components=1 if [ ! -d unix/xserver/include ]; then
tar -C unix/xserver -xf /tmp/"$TARBALL" --strip-components=1
cd unix/xserver cd unix/xserver
# Apply patches # Apply patches
patch -Np1 -i ../xserver${XORG_PATCH}.patch patch -Np1 -i ../xserver"${XORG_PATCH}".patch
case "$XORG_VER" in case "$XORG_VER" in
1.20.*) 1.20.*)
patch -s -p0 < ../CVE-2022-2320-v1.20.patch patch -s -p0 < ../CVE-2022-2320-v1.20.patch
if [ -f ../xserver120.7.patch ]; then if [ -f ../xserver120.7.patch ]; then
@ -75,20 +75,20 @@ case "$XORG_VER" in
1.19.*) 1.19.*)
patch -s -p0 < ../CVE-2022-2320-v1.19.patch patch -s -p0 < ../CVE-2022-2320-v1.19.patch
;; ;;
esac esac
autoreconf -i autoreconf -i
# Configuring Xorg is long and has many distro-specific paths. # Configuring Xorg is long and has many distro-specific paths.
# The distro paths start after prefix and end with the font path, # The distro paths start after prefix and end with the font path,
# everything after that is based on BUILDING.txt to remove unneeded # everything after that is based on BUILDING.txt to remove unneeded
# components. # components.
# remove gl check for opensuse # remove gl check for opensuse
if [ "${KASMVNC_BUILD_OS}" == "opensuse" ] || ([ "${KASMVNC_BUILD_OS}" == "oracle" ] && [ "${KASMVNC_BUILD_OS_CODENAME}" == 9 ]); then if [ "${KASMVNC_BUILD_OS}" == "opensuse" ] || ([ "${KASMVNC_BUILD_OS}" == "oracle" ] && [ "${KASMVNC_BUILD_OS_CODENAME}" == 9 ]); then
sed -i 's/LIBGL="gl >= 7.1.0"/LIBGL="gl >= 1.1"/g' configure sed -i 's/LIBGL="gl >= 7.1.0"/LIBGL="gl >= 1.1"/g' configure
fi fi
# build X11 # build X11
./configure \ ./configure \
--disable-config-hal \ --disable-config-hal \
--disable-config-udev \ --disable-config-udev \
--disable-dmx \ --disable-dmx \
@ -110,33 +110,37 @@ fi
--with-sha1=libcrypto \ --with-sha1=libcrypto \
--with-xkb-bin-directory=/usr/bin \ --with-xkb-bin-directory=/usr/bin \
--with-xkb-output=/var/lib/xkb \ --with-xkb-output=/var/lib/xkb \
--with-xkb-path=/usr/share/X11/xkb ${CONFIG_OPTIONS} --with-xkb-path=/usr/share/X11/xkb "${CONFIG_OPTIONS}"
# remove array bounds errors for new versions of GCC # remove array bounds errors for new versions of GCC
find . -name "Makefile" -exec sed -i 's/-Werror=array-bounds//g' {} \; find . -name "Makefile" -exec sed -i 's/-Werror=array-bounds//g' {} \;
make -j5 fi
make -j"$(nproc)"
# modifications for the servertarball # modifications for the servertarball
cd /src cd /src
mkdir -p xorg.build/bin mkdir -p xorg.build/bin
cd xorg.build/bin/ cd xorg.build/bin/
ln -s /src/unix/xserver/hw/vnc/Xvnc Xvnc ln -sfn /src/unix/xserver/hw/vnc/Xvnc Xvnc
cd .. cd ..
mkdir -p man/man1 mkdir -p man/man1
touch man/man1/Xserver.1 touch man/man1/Xserver.1
cp /src/unix/xserver/hw/vnc/Xvnc.man man/man1/Xvnc.1 cp /src/unix/xserver/hw/vnc/Xvnc.man man/man1/Xvnc.1
mkdir lib
mkdir -p lib
cd lib cd lib
if [ -d /usr/lib/x86_64-linux-gnu/dri ]; then if [ -d /usr/lib/x86_64-linux-gnu/dri ]; then
ln -s /usr/lib/x86_64-linux-gnu/dri dri ln -sfn /usr/lib/x86_64-linux-gnu/dri dri
elif [ -d /usr/lib/aarch64-linux-gnu/dri ]; then elif [ -d /usr/lib/aarch64-linux-gnu/dri ]; then
ln -s /usr/lib/aarch64-linux-gnu/dri dri ln -sfn /usr/lib/aarch64-linux-gnu/dri dri
elif [ -d /usr/lib/arm-linux-gnueabihf/dri ]; then elif [ -d /usr/lib/arm-linux-gnueabihf/dri ]; then
ln -s /usr/lib/arm-linux-gnueabihf/dri dri ln -sfn /usr/lib/arm-linux-gnueabihf/dri dri
elif [ -d /usr/lib/xorg/modules/dri ]; then elif [ -d /usr/lib/xorg/modules/dri ]; then
ln -s /usr/lib/xorg/modules/dri dri ln -sfn /usr/lib/xorg/modules/dri dri
else else
ln -s /usr/lib64/dri dri ln -sfn /usr/lib64/dri dri
fi fi
cd /src cd /src

View File

@ -14,6 +14,7 @@ RUN \
bash \ bash \
ca-certificates \ ca-certificates \
cmake \ cmake \
nasm \
coreutils \ coreutils \
curl \ curl \
eudev-dev \ eudev-dev \

View File

@ -14,6 +14,7 @@ RUN \
bash \ bash \
ca-certificates \ ca-certificates \
cmake \ cmake \
nasm \
coreutils \ coreutils \
curl \ curl \
eudev-dev \ eudev-dev \

View File

@ -14,6 +14,7 @@ RUN \
bash \ bash \
ca-certificates \ ca-certificates \
cmake \ cmake \
nasm \
coreutils \ coreutils \
curl \ curl \
eudev-dev \ eudev-dev \

View File

@ -14,6 +14,7 @@ RUN \
bash \ bash \
ca-certificates \ ca-certificates \
cmake \ cmake \
nasm \
coreutils \ coreutils \
curl \ curl \
eudev-dev \ eudev-dev \

View File

@ -22,7 +22,7 @@ RUN apt-get update && \
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
RUN apt-get update && apt-get -y install cmake git libgnutls28-dev vim wget tightvncserver curl RUN apt-get update && apt-get -y install ninja-build cmake nasm git libgnutls28-dev vim wget tightvncserver curl
RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev
ENV SCRIPTS_DIR=/tmp/scripts ENV SCRIPTS_DIR=/tmp/scripts

View File

@ -12,7 +12,7 @@ RUN apt-get update && \
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
RUN apt-get update && apt-get -y install git libgnutls28-dev vim wget tightvncserver curl RUN apt-get update && apt-get -y install ninja-build nasm git libgnutls28-dev vim wget tightvncserver curl
RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev
RUN CMAKE_URL="https://cmake.org/files/v3.22/cmake-3.22.0" && \ RUN CMAKE_URL="https://cmake.org/files/v3.22/cmake-3.22.0" && \

View File

@ -12,7 +12,7 @@ RUN apt-get update && \
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
RUN apt-get update && apt-get -y install cmake git libgnutls28-dev vim wget tightvncserver curl RUN apt-get update && apt-get -y install ninja-build cmake nasm git libgnutls28-dev vim wget tightvncserver curl
RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev
ENV SCRIPTS_DIR=/tmp/scripts ENV SCRIPTS_DIR=/tmp/scripts

View File

@ -16,6 +16,7 @@ RUN \
byacc \ byacc \
bzip2 \ bzip2 \
cmake \ cmake \
nasm \
diffutils \ diffutils \
doxygen \ doxygen \
file \ file \

View File

@ -17,6 +17,7 @@ RUN \
byacc \ byacc \
bzip2 \ bzip2 \
cmake \ cmake \
nasm \
diffutils \ diffutils \
doxygen \ doxygen \
file \ file \

View File

@ -16,6 +16,7 @@ RUN \
byacc \ byacc \
bzip2 \ bzip2 \
cmake \ cmake \
nasm \
diffutils \ diffutils \
doxygen \ doxygen \
file \ file \

View File

@ -13,7 +13,7 @@ RUN apt-get update && \
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
RUN apt-get update && apt-get -y install gcc g++ curl RUN apt-get update && apt-get -y install gcc g++ curl
RUN apt-get update && apt-get -y install cmake git libgnutls28-dev vim wget tightvncserver RUN apt-get update && apt-get -y install ninja-build cmake nasm git libgnutls28-dev vim wget tightvncserver
RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev
ENV SCRIPTS_DIR=/tmp/scripts ENV SCRIPTS_DIR=/tmp/scripts

View File

@ -8,7 +8,9 @@ ENV XORG_VER 1.20.3
RUN zypper install -ny \ RUN zypper install -ny \
bdftopcf \ bdftopcf \
bigreqsproto-devel \ bigreqsproto-devel \
ninja \
cmake \ cmake \
nasm \
curl \ curl \
ffmpeg-4-libavcodec-devel \ ffmpeg-4-libavcodec-devel \
fonttosfnt \ fonttosfnt \

View File

@ -11,7 +11,9 @@ RUN \
dnf install -y \ dnf install -y \
bzip2-devel \ bzip2-devel \
ca-certificates \ ca-certificates \
ninja-build \
cmake \ cmake \
nasm \
dnf-plugins-core \ dnf-plugins-core \
gcc \ gcc \
gcc-c++ \ gcc-c++ \

View File

@ -11,7 +11,9 @@ RUN \
dnf install -y \ dnf install -y \
bzip2-devel \ bzip2-devel \
ca-certificates \ ca-certificates \
ninja-build \
cmake \ cmake \
nasm \
dnf-plugins-core \ dnf-plugins-core \
gcc \ gcc \
gcc-c++ \ gcc-c++ \

View File

@ -12,13 +12,11 @@ RUN apt-get update && \
RUN apt-get update && apt-get install -y --no-install-recommends tzdata RUN apt-get update && apt-get install -y --no-install-recommends tzdata
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
RUN apt-get update && apt-get -y install cmake git vim wget curl RUN apt-get update && apt-get -y install ninja-build nasm git vim wget curl
RUN apt-get update && apt-get -y install libtbb-dev libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev RUN apt-get update && apt-get -y install libtbb-dev libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev
ENV SCRIPTS_DIR=/tmp/scripts ENV SCRIPTS_DIR=/tmp/scripts
COPY builder/scripts $SCRIPTS_DIR COPY builder/scripts $SCRIPTS_DIR
RUN $SCRIPTS_DIR/build-webp
RUN $SCRIPTS_DIR/build-libjpeg-turbo
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
@ -35,6 +33,9 @@ RUN ARCH=$(arch) && \
(echo y; echo n) | bash cmake.sh --prefix=/usr/local --skip-license && \ (echo y; echo n) | bash cmake.sh --prefix=/usr/local --skip-license && \
rm cmake.sh rm cmake.sh
RUN $SCRIPTS_DIR/build-webp
RUN $SCRIPTS_DIR/build-libjpeg-turbo
COPY --chown=docker:docker . /src/ COPY --chown=docker:docker . /src/
USER docker USER docker

View File

@ -12,7 +12,7 @@ RUN apt-get update && \
RUN apt-get update && apt-get install -y --no-install-recommends tzdata RUN apt-get update && apt-get install -y --no-install-recommends tzdata
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
RUN apt-get update && apt-get -y install cmake git libgnutls28-dev vim wget tightvncserver curl RUN apt-get update && apt-get -y install ninja-build cmake nasm git libgnutls28-dev vim wget tightvncserver curl
RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev
ENV SCRIPTS_DIR=/tmp/scripts ENV SCRIPTS_DIR=/tmp/scripts

View File

@ -12,12 +12,56 @@ USER root
RUN sed -i 's$# deb-src$deb-src$' /etc/apt/sources.list && \ RUN sed -i 's$# deb-src$deb-src$' /etc/apt/sources.list && \
apt update && \ apt update && \
apt install -y socat sudo libxfont-dev cmake git libgnutls28-dev vim wget tightvncserver curl libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev pkg-config libfreetype6-dev libxtst-dev autoconf automake libtool xutils-dev libpixman-1-dev libxshmfence-dev libxcvt-dev libxkbfile-dev x11proto-dev libgbm-dev inotify-tools && \ apt install -y \
ninja-build \
gdb \
valgrind \
rsync \
dos2unix \
socat \
sudo \
libxfont-dev \
cmake \
nasm \
git \
libgnutls28-dev \
vim \
wget \
tightvncserver \
curl \
libpng-dev \
libtiff-dev \
libgif-dev \
libavcodec-dev \
libssl-dev \
libxrandr-dev \
libxcursor-dev \
pkg-config \
libfreetype6-dev \
libxtst-dev \
autoconf \
automake \
libtool \
xutils-dev \
libpixman-1-dev \
libxshmfence-dev \
libxcvt-dev \
libxkbfile-dev \
x11proto-dev \
libgbm-dev \
inotify-tools && \
echo "kasm-user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers echo "kasm-user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - RUN curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
RUN apt install -y nodejs RUN apt install -y nodejs
COPY builder/scripts/build-webp /tmp
COPY builder/scripts/build-libjpeg-turbo /tmp
COPY builder/common.sh /tmp
RUN chmod +x /tmp/build-webp && /tmp/build-webp
RUN chmod +x /tmp/build-libjpeg-turbo && /tmp/build-libjpeg-turbo
USER 1000 USER 1000
WORKDIR /src WORKDIR /src

View File

@ -12,7 +12,7 @@ RUN apt-get update && \
RUN apt-get update && apt-get install -y --no-install-recommends tzdata RUN apt-get update && apt-get install -y --no-install-recommends tzdata
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
RUN apt-get update && apt-get -y install cmake git libgnutls28-dev vim wget curl RUN apt-get update && apt-get -y install ninja-build cmake nasm git libgnutls28-dev vim wget curl
RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev
ENV SCRIPTS_DIR=/tmp/scripts ENV SCRIPTS_DIR=/tmp/scripts

View File

@ -3,20 +3,8 @@
set -euo pipefail set -euo pipefail
build_and_install() { build_and_install() {
export MAKEFLAGS=-j`nproc` cmake -B build -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_POSITION_INDEPENDENT_CODE=ON -GNinja .
export CFLAGS="-fpic" ninja -C build install
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -G"Unix Makefiles"
make
make install
}
install_build_dependencies() {
install_packages cmake gcc
ensure_libjpeg_is_fast
}
ensure_libjpeg_is_fast() {
install_packages nasm
} }
prepare_libjpeg_source() { prepare_libjpeg_source() {
@ -32,6 +20,5 @@ prepare_libjpeg_source() {
source_dir=$(dirname "$0") source_dir=$(dirname "$0")
. "$source_dir/common.sh" . "$source_dir/common.sh"
install_build_dependencies
prepare_libjpeg_source prepare_libjpeg_source
build_and_install build_and_install