From 91eb953f627c4a4532bfdd52198865d145c22c83 Mon Sep 17 00:00:00 2001 From: Dmitry Maksyoma Date: Wed, 8 Sep 2021 00:11:21 +1200 Subject: [PATCH] Feature/kasm 1838 libjpeg turbo from source (#49) New build option with latest stable libjpeg-turbo library --- .ci/upload.sh | 35 ++++++++++- .dockerignore | 1 - .gitlab-ci.yml | 14 ++++- builder/README.md | 22 ++++++- builder/build-deb | 17 ++++-- builder/build-deb-inside-docker | 21 ++++++- builder/build-package | 14 ++++- builder/build-rpm | 10 ++++ builder/build-tarball | 23 ++++++-- builder/build.sh | 4 ++ builder/dockerfile.debian_bullseye.deb.build | 9 ++- builder/dockerfile.debian_bullseye.deb.test | 4 +- ...ockerfile.debian_buster.barebones.deb.test | 4 +- builder/dockerfile.debian_buster.deb.build | 9 ++- builder/dockerfile.debian_buster.deb.test | 4 +- .../dockerfile.kali_kali-rolling.deb.build | 9 ++- builder/dockerfile.kali_kali-rolling.deb.test | 4 +- ...e.ubuntu_bionic+libjpeg-turbo_latest.build | 39 +++++++++++++ ...untu_bionic+libjpeg-turbo_latest.deb.build | 23 ++++++++ ...buntu_bionic+libjpeg-turbo_latest.deb.test | 58 +++++++++++++++++++ builder/dockerfile.ubuntu_bionic.deb.build | 9 ++- builder/dockerfile.ubuntu_bionic.deb.test | 4 +- ...dockerfile.ubuntu_focal.barebones.deb.test | 4 +- builder/dockerfile.ubuntu_focal.deb.build | 9 ++- builder/dockerfile.ubuntu_focal.deb.test | 4 +- builder/os_ver_cli.sh | 5 ++ builder/test-deb | 8 ++- debian/Makefile.to_fakebuild_tar_package | 2 +- 28 files changed, 328 insertions(+), 41 deletions(-) delete mode 100644 .dockerignore create mode 100644 builder/dockerfile.ubuntu_bionic+libjpeg-turbo_latest.build create mode 100644 builder/dockerfile.ubuntu_bionic+libjpeg-turbo_latest.deb.build create mode 100644 builder/dockerfile.ubuntu_bionic+libjpeg-turbo_latest.deb.test diff --git a/.ci/upload.sh b/.ci/upload.sh index f2fa0e5..ce810cf 100644 --- a/.ci/upload.sh +++ b/.ci/upload.sh @@ -1,16 +1,33 @@ #!/bin/bash +is_kasmvnc() { + local package="$1"; + + echo "$package" | grep -q 'kasmvncserver_' +} + function prepare_upload_filename() { local package="$1"; + if ! is_kasmvnc "$package"; then + export upload_filename="$package" + return + fi + .ci/detect_os_arch_package_format "$package" > /tmp/os_arch_package_format; source /tmp/os_arch_package_format; detect_release_branch + + detect_revision "$package" "$OS_ARCH" + if [ -n "$REVISION" ]; then + REVISION="_${REVISION}" + fi + if [ -n "$RELEASE_BRANCH" ]; then - export upload_filename="kasmvncserver_${PACKAGE_OS}_${RELEASE_VERSION}_${OS_ARCH}.${PACKAGE_FORMAT}"; + export upload_filename="kasmvncserver_${PACKAGE_OS}_${RELEASE_VERSION}${REVISION}_${OS_ARCH}.${PACKAGE_FORMAT}"; else export SANITIZED_BRANCH="$(echo $CI_COMMIT_REF_NAME | sed 's/\//_/g')"; - export upload_filename="kasmvncserver_${PACKAGE_OS}_${RELEASE_VERSION}_${SANITIZED_BRANCH}_${CI_COMMIT_SHA:0:6}_${OS_ARCH}.${PACKAGE_FORMAT}"; + export upload_filename="kasmvncserver_${PACKAGE_OS}_${RELEASE_VERSION}_${SANITIZED_BRANCH}_${CI_COMMIT_SHA:0:6}${REVISION}_${OS_ARCH}.${PACKAGE_FORMAT}"; fi }; @@ -25,6 +42,7 @@ function upload_to_s3() { export BUILD_STATUS="{\"key\":\"doc\", \"state\":\"SUCCESSFUL\", \"name\":\"${upload_filename}\", \"url\":\"${S3_URL}\"}"; curl --request POST --header "PRIVATE-TOKEN:${GITLAB_API_TOKEN}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/statuses/${CI_COMMIT_SHA}?state=success&name=build-url&target_url=${S3_URL}"; }; + function prepare_to_run_scripts_and_s3_uploads() { export DEBIAN_FRONTEND=noninteractive; apt-get update; @@ -38,3 +56,16 @@ detect_release_branch() { export RELEASE_BRANCH=1; fi } + +detect_revision() { + local package="$1" + local arch="$2" + + REVISION= + + if ! echo "$package" | grep -q '+'; then + return + fi + + REVISION=$(echo "$package" | sed "s/_${arch}.\+//" | sed 's/.\++//') +} diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index e052dcf..0000000 --- a/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -builder/build diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 040fc5d..c8584fb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,6 +34,18 @@ build_ubuntu_bionic: paths: - output/ +build_ubuntu_bionic_libjpeg_turbo: + stage: build + before_script: + - *prepare_build + after_script: + - *prepare_artfacts + script: + - bash builder/build-package ubuntu bionic +libjpeg-turbo_latest + artifacts: + paths: + - output/ + build_ubuntu_focal: stage: build before_script: @@ -103,7 +115,7 @@ upload: - export S3_BUILD_DIRECTORY="kasmvnc/${CI_COMMIT_SHA}" - prepare_to_run_scripts_and_s3_uploads - export RELEASE_VERSION=$(.ci/next_release_version "$CI_COMMIT_REF_NAME") - - for package in `find output/ -type f -name 'kasmvncserver_*.deb' -or -name '*.rpm'`; do + - for package in `find output/ -type f -name '*.deb' -or -name '*.rpm'`; do prepare_upload_filename "$package"; echo; echo "File to upload $upload_filename"; diff --git a/builder/README.md b/builder/README.md index d8c8f56..acae94e 100644 --- a/builder/README.md +++ b/builder/README.md @@ -3,8 +3,17 @@ Docker CE # Build a deb/rpm package ``` -# builder/build-package +# builder/build-package # os_codename is what "lsb_release -c" outputs, e.g. buster, focal. +# +# build_tag allows building multiple versions of deb package (rpm not supported) +# targeting a single distro release (e.g. Ubuntu Bionic). If build_tag is given, +# the package name will include build_tag as part of Debian revision. For +# example: +# * with build_tag: kasmvncserver_0.9.1~beta-1+libjpeg-turbo-latest_amd64.deb +# * without build_tag: kasmvncserver_0.9.1~beta-1_amd64.deb +# You need to have .build and .deb.build for the build_tag. +# # Packages will be placed under builder/build/ builder/build-package ubuntu bionic @@ -70,3 +79,14 @@ packages installed with XFCE. ``` builder/test-deb-barebones ubuntu focal ``` +# CI development + +S3 upload code is extracted to various files in `.ci`. It's possible to iterate +locally by doing stuff like this: + +``` +bash -c ' +. .ci/upload.sh; +prepare_upload_filename "bionic/kasmvncserver_0.9.1~beta-1+libjpeg-turbo-latest_amd64.deb"; +echo $upload_filename;' +``` diff --git a/builder/build-deb b/builder/build-deb index 73751ef..e2e1093 100755 --- a/builder/build-deb +++ b/builder/build-deb @@ -5,12 +5,17 @@ set -e cd "$(dirname "$0")/.." . builder/os_ver_cli.sh -docker build -t debbuilder_${os}:${os_codename} -f \ - builder/dockerfile.${os}_${os_codename}.deb.build . - -deb_output_dir=$(cd .. && echo $PWD) L_UID=$(id -u) #Ubuntu already has UID env var, but this should work on all Linix systems L_GID=$(id -g) -docker run --rm -v "$deb_output_dir":/src --user $L_UID:$L_GID \ - debbuilder_${os}:${os_codename} /bin/bash -c \ + +builder_image=debbuilder_${os}:${os_codename}${build_tag_for_images} +docker build --build-arg KASMVNC_PACKAGE_DIR="builder/build/${os_codename}" \ + --build-arg L_UID="$L_UID" \ + -t "$builder_image" -f \ + builder/dockerfile.${os}_${os_codename}${build_tag}.deb.build . + +deb_output_dir=$(cd .. && echo $PWD) +docker run --rm -v "$deb_output_dir":/src -e BUILD_TAG="$build_tag" \ + --user "$L_UID:$L_GID" \ + "$builder_image" /bin/bash -c \ '/src/*/builder/build-deb-inside-docker' diff --git a/builder/build-deb-inside-docker b/builder/build-deb-inside-docker index faca5d0..734b846 100755 --- a/builder/build-deb-inside-docker +++ b/builder/build-deb-inside-docker @@ -2,12 +2,31 @@ set -e -cd "$(dirname "$0")/.." +prepare_docker_copy_of_debian_dir_and_cd_to_id() { + cd "$(dirname "$0")/.." + + local mounted_src_dir="$PWD" + local docker_src_dir="$HOME/src" + + mkdir "$docker_src_dir" + cd "$docker_src_dir" + cp -a "$mounted_src_dir/debian/" . + ln -s "$mounted_src_dir/builder" . +} + +prepare_docker_copy_of_debian_dir_and_cd_to_id os=$(lsb_release -is | tr '[:upper:]' '[:lower:]') os_codename=$(lsb_release -cs) os_dir="builder/build/${os_codename}" +if [ "$BUILD_TAG" = "+libjpeg-turbo_latest" ]; then + echo 'libjpeg 62 libjpeg-turbo (>= 2.1.1)' > debian/shlibs.local + + debian_revision="$(echo $BUILD_TAG | tr _ -)" + sed -i -e "1 s/)/$debian_revision)/" debian/changelog +fi + dpkg-buildpackage -us -uc -b mkdir -p "$os_dir" cp ../*.deb "$os_dir" diff --git a/builder/build-package b/builder/build-package index a21bf01..9718846 100755 --- a/builder/build-package +++ b/builder/build-package @@ -4,6 +4,7 @@ set -e os="$1" codename="$2" +build_tag="$3" detect_package_format() { package_format=rpm @@ -12,8 +13,17 @@ detect_package_format() { fi } +warn_build_tag_not_supported_for_rpm_and_exit() { + if [[ "$build_tag" && "$package_format" = "rpm" ]]; then + echo >&2 " isn't supported for rpm" + exit 1 + fi +} + cd "$(dirname "$0")/.." detect_package_format -builder/build-tarball "$os" "$codename" -builder/build-${package_format} "$os" "$codename" +warn_build_tag_not_supported_for_rpm_and_exit + +builder/build-tarball "$os" "$codename" "$build_tag" +builder/build-${package_format} "$os" "$codename" "$build_tag" diff --git a/builder/build-rpm b/builder/build-rpm index 39724d5..f3fdf2d 100755 --- a/builder/build-rpm +++ b/builder/build-rpm @@ -2,8 +2,18 @@ set -e +warn_build_tag_not_supported_for_rpm_and_exit() { + local build_tag="$1" + + if [[ -n "$build_tag" ]]; then + echo >&2 " isn't supported for rpm" + exit 1 + fi +} + cd "$(dirname "$0")/.." . builder/os_ver_cli.sh +warn_build_tag_not_supported_for_rpm_and_exit "$build_tag" docker build -t kasmvnc_rpmbuilder_${os}:${os_codename} -f \ builder/dockerfile.${os}_${os_codename}.rpm.build . diff --git a/builder/build-tarball b/builder/build-tarball index 3cf9d2f..3a85a8e 100755 --- a/builder/build-tarball +++ b/builder/build-tarball @@ -12,6 +12,13 @@ build_www_dir() { fi } +move_libjpeg_turbo_to_os_specific_dir() { + chown $L_UID:$L_GID $shared_with_docker_dir/${os_codename}/* + mkdir -p $PWD/builder/build/${os_codename}/ + mv $shared_with_docker_dir/${os_codename}/libjpeg-turbo*.deb \ + $PWD/builder/build/${os_codename}/ +} + shared_with_docker_dir=${GITLAB_SHARED_DIND_DIR:-/tmp} cd "$(dirname "$0")/.." @@ -19,13 +26,21 @@ cd "$(dirname "$0")/.." build_www_dir -docker build -t kasmvncbuilder:$os_codename \ - -f builder/dockerfile.${os}_${os_codename}.build . +builder_image=kasmvncbuilder:$os_codename${build_tag_for_images} +docker build -t "$builder_image" \ + -f builder/dockerfile.${os}_${os_codename}${build_tag}.build . mkdir -p builder/build -docker run -v $shared_with_docker_dir:/build --rm kasmvncbuilder:$os_codename +docker run -v $shared_with_docker_dir:/build -e BUILD_TAG="$build_tag" \ + --rm "$builder_image" L_GID=$(id -g) L_UID=$(id -u) tarball_name="kasmvnc.${os}_${os_codename}.tar.gz" +tarball_name_with_build_tag="kasmvnc.${os}_${os_codename}${build_tag}.tar.gz" chown $L_UID:$L_GID $shared_with_docker_dir/$tarball_name -mv $shared_with_docker_dir/$tarball_name $PWD/builder/build/ +mv $shared_with_docker_dir/$tarball_name \ + $PWD/builder/build/"$tarball_name_with_build_tag" + +if [ "$build_tag" = "+libjpeg-turbo_latest" ]; then + move_libjpeg_turbo_to_os_specific_dir +fi diff --git a/builder/build.sh b/builder/build.sh index 75794db..4192f36 100755 --- a/builder/build.sh +++ b/builder/build.sh @@ -84,3 +84,7 @@ fi make servertarball cp kasmvnc*.tar.gz /build/kasmvnc.${KASMVNC_BUILD_OS}_${KASMVNC_BUILD_OS_CODENAME}.tar.gz +if [ "$BUILD_TAG" = "+libjpeg-turbo_latest" ]; then + mkdir -p /build/${KASMVNC_BUILD_OS_CODENAME}/ + cp /libjpeg-turbo/libjpeg*.deb /build/${KASMVNC_BUILD_OS_CODENAME}/ +fi diff --git a/builder/dockerfile.debian_bullseye.deb.build b/builder/dockerfile.debian_bullseye.deb.build index 732c6a6..51bde4f 100644 --- a/builder/dockerfile.debian_bullseye.deb.build +++ b/builder/dockerfile.debian_bullseye.deb.build @@ -9,4 +9,11 @@ RUN apt-get update && \ COPY ./debian/control /tmp RUN apt-get update && echo YYY | mk-build-deps --install --remove /tmp/control -USER 1000 +ARG L_UID +RUN if [ "$L_UID" -eq 0 ]; then \ + useradd -m docker; \ + else \ + useradd -m docker -u $L_UID;\ + fi + +USER docker diff --git a/builder/dockerfile.debian_bullseye.deb.test b/builder/dockerfile.debian_bullseye.deb.test index 3ad2600..90ee85d 100644 --- a/builder/dockerfile.debian_bullseye.deb.test +++ b/builder/dockerfile.debian_bullseye.deb.test @@ -42,8 +42,8 @@ COPY startup/ $STARTUPDIR ### START CUSTOM STUFF #### ARG KASMVNC_PACKAGE_DIR -COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp -RUN dpkg -i /tmp/*.deb; apt-get -yf install +COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp/ +RUN rm -f /tmp/kasmvncserver_*+*.deb; dpkg -i /tmp/*.deb; apt-get -yf install ### END CUSTOM STUFF ### diff --git a/builder/dockerfile.debian_buster.barebones.deb.test b/builder/dockerfile.debian_buster.barebones.deb.test index 12049c6..43147af 100644 --- a/builder/dockerfile.debian_buster.barebones.deb.test +++ b/builder/dockerfile.debian_buster.barebones.deb.test @@ -1,8 +1,8 @@ FROM debian:buster-slim ARG KASMVNC_PACKAGE_DIR -COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp -RUN apt-get update && dpkg -i /tmp/*.deb; apt-get -yf install +COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp/ +RUN rm -f /tmp/kasmvncserver_*+*.deb; apt-get update && dpkg -i /tmp/*.deb; apt-get -yf install RUN apt-get update && apt-get -y install xterm COPY startup/deb/kasmvncserver-easy-start /usr/local/bin diff --git a/builder/dockerfile.debian_buster.deb.build b/builder/dockerfile.debian_buster.deb.build index 9ca2b88..eb3a6bf 100644 --- a/builder/dockerfile.debian_buster.deb.build +++ b/builder/dockerfile.debian_buster.deb.build @@ -9,4 +9,11 @@ RUN apt-get update && \ COPY ./debian/control /tmp RUN apt-get update && echo YYY | mk-build-deps --install --remove /tmp/control -USER 1000 +ARG L_UID +RUN if [ "$L_UID" -eq 0 ]; then \ + useradd -m docker; \ + else \ + useradd -m docker -u $L_UID;\ + fi + +USER docker diff --git a/builder/dockerfile.debian_buster.deb.test b/builder/dockerfile.debian_buster.deb.test index ef536ea..5b3753c 100644 --- a/builder/dockerfile.debian_buster.deb.test +++ b/builder/dockerfile.debian_buster.deb.test @@ -42,8 +42,8 @@ COPY startup/ $STARTUPDIR ### START CUSTOM STUFF #### ARG KASMVNC_PACKAGE_DIR -COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp -RUN dpkg -i /tmp/*.deb; apt-get -yf install +COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp/ +RUN rm -f /tmp/kasmvncserver_*+*.deb; dpkg -i /tmp/*.deb; apt-get -yf install ### END CUSTOM STUFF ### diff --git a/builder/dockerfile.kali_kali-rolling.deb.build b/builder/dockerfile.kali_kali-rolling.deb.build index 240bd69..6d0ed1b 100644 --- a/builder/dockerfile.kali_kali-rolling.deb.build +++ b/builder/dockerfile.kali_kali-rolling.deb.build @@ -9,4 +9,11 @@ RUN apt-get update && \ COPY ./debian/control /tmp RUN apt-get update && echo YYY | mk-build-deps --install --remove /tmp/control -USER 1000 +ARG L_UID +RUN if [ "$L_UID" -eq 0 ]; then \ + useradd -m docker; \ + else \ + useradd -m docker -u $L_UID;\ + fi + +USER docker diff --git a/builder/dockerfile.kali_kali-rolling.deb.test b/builder/dockerfile.kali_kali-rolling.deb.test index a189b9b..5d95f99 100644 --- a/builder/dockerfile.kali_kali-rolling.deb.test +++ b/builder/dockerfile.kali_kali-rolling.deb.test @@ -42,8 +42,8 @@ COPY startup/ $STARTUPDIR ### START CUSTOM STUFF #### ARG KASMVNC_PACKAGE_DIR -COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp -RUN dpkg -i /tmp/*.deb; apt-get -yf install +COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp/ +RUN rm -f /tmp/kasmvncserver_*+*.deb; dpkg -i /tmp/*.deb; apt-get -yf install ### END CUSTOM STUFF ### diff --git a/builder/dockerfile.ubuntu_bionic+libjpeg-turbo_latest.build b/builder/dockerfile.ubuntu_bionic+libjpeg-turbo_latest.build new file mode 100644 index 0000000..7f6ca1d --- /dev/null +++ b/builder/dockerfile.ubuntu_bionic+libjpeg-turbo_latest.build @@ -0,0 +1,39 @@ +FROM ubuntu:18.04 + +ENV KASMVNC_BUILD_OS ubuntu +ENV KASMVNC_BUILD_OS_CODENAME bionic +ENV XORG_VER 1.20.10 + +RUN sed -i 's$# deb-src$deb-src$' /etc/apt/sources.list + +RUN apt-get update && \ + apt-get -y install sudo + +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 +RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev + +RUN apt-get update && apt-get install -y cmake nasm gcc +RUN git clone https://github.com/libjpeg-turbo/libjpeg-turbo.git +RUN export MAKEFLAGS=-j`nproc`; cd libjpeg-turbo && cmake -G"Unix Makefiles" && make deb +RUN export MAKEFLAGS=-j`nproc`; cd libjpeg-turbo && cmake -DCMAKE_INSTALL_PREFIX=/usr/local -G"Unix Makefiles" && make && make install + +# Additions for webp +RUN cd /tmp && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz +RUN cd /tmp && tar -xzvf /tmp/libwebp-* +RUN cd /tmp/libwebp-1.0.2 && \ + ./configure --enable-static --disable-shared && \ + make && make install + +# Fix for older required libs +#RUN cd /tmp && wget http://launchpadlibrarian.net/347526424/libxfont1-dev_1.5.2-4ubuntu2_amd64.deb && \ +# wget http://launchpadlibrarian.net/347526425/libxfont1_1.5.2-4ubuntu2_amd64.deb && \ +# dpkg -i libxfont1_1.5.2-4ubuntu2_amd64.deb && \ +# dpkg -i libxfont1-dev_1.5.2-4ubuntu2_amd64.deb + +RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo + +COPY --chown=docker:docker . /src + +USER docker +ENTRYPOINT ["/src/builder/build.sh"] diff --git a/builder/dockerfile.ubuntu_bionic+libjpeg-turbo_latest.deb.build b/builder/dockerfile.ubuntu_bionic+libjpeg-turbo_latest.deb.build new file mode 100644 index 0000000..ab88621 --- /dev/null +++ b/builder/dockerfile.ubuntu_bionic+libjpeg-turbo_latest.deb.build @@ -0,0 +1,23 @@ +FROM ubuntu:bionic + +RUN apt-get update && \ + apt-get -y install vim build-essential devscripts equivs + +ARG KASMVNC_PACKAGE_DIR +COPY $KASMVNC_PACKAGE_DIR/libjpeg-turbo*deb /tmp +RUN apt-get install /tmp/libjpeg-turbo*deb + +# Install build-deps for the package. +COPY ./debian/control /tmp +RUN apt-get update && echo YYY | mk-build-deps --install --remove /tmp/control + +ENV LD_LIBRARY_PATH="/opt/libjpeg-turbo/lib64/:$LD_LIBRARY_PATH" + +ARG L_UID +RUN if [ "$L_UID" -eq 0 ]; then \ + useradd -m docker; \ + else \ + useradd -m docker -u $L_UID;\ + fi + +USER docker diff --git a/builder/dockerfile.ubuntu_bionic+libjpeg-turbo_latest.deb.test b/builder/dockerfile.ubuntu_bionic+libjpeg-turbo_latest.deb.test new file mode 100644 index 0000000..9f3236b --- /dev/null +++ b/builder/dockerfile.ubuntu_bionic+libjpeg-turbo_latest.deb.test @@ -0,0 +1,58 @@ +FROM ubuntu:bionic + +ENV DISPLAY=:1 \ + VNC_PORT=8443 \ + VNC_RESOLUTION=1280x720 \ + MAX_FRAME_RATE=24 \ + VNCOPTIONS="-PreferBandwidth -DynamicQualityMin=4 -DynamicQualityMax=7" \ + HOME=/home/user \ + TERM=xterm \ + STARTUPDIR=/dockerstartup \ + INST_SCRIPTS=/dockerstartup/install \ + KASM_RX_HOME=/dockerstartup/kasmrx \ + DEBIAN_FRONTEND=noninteractive \ + VNC_COL_DEPTH=24 \ + VNC_RESOLUTION=1280x1024 \ + VNC_PW=vncpassword \ + VNC_USER=user \ + VNC_VIEW_ONLY_PW=vncviewonlypassword \ + LD_LIBRARY_PATH=/opt/libjpeg-turbo/lib64/:/usr/local/lib/ \ + OMP_WAIT_POLICY=PASSIVE \ + SHELL=/bin/bash \ + SINGLE_APPLICATION=0 \ + KASMVNC_BUILD_OS=ubuntu \ + KASMVNC_BUILD_OS_CODENAME=bionic + +EXPOSE $VNC_PORT + +WORKDIR $HOME + +### REQUIRED STUFF ### + +RUN apt-get update && apt-get install -y supervisor xfce4 xfce4-terminal xterm libnss-wrapper gettext wget +RUN apt-get purge -y pm-utils xscreensaver* +RUN apt-get update && apt-get install -y vim less +RUN apt-get update && apt-get -y install lsb-release + +RUN echo 'source $STARTUPDIR/generate_container_user' >> $HOME/.bashrc + +RUN mkdir -p $STARTUPDIR +COPY startup/ $STARTUPDIR + +### START CUSTOM STUFF #### + +ARG KASMVNC_PACKAGE_DIR +COPY $KASMVNC_PACKAGE_DIR/libjpeg-turbo_*.deb /tmp +RUN apt-get install /tmp/libjpeg-turbo*deb + +ARG BUILD_DEBIAN_REVISION +COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*$BUILD_DEBIAN_REVISION*.deb /tmp +RUN dpkg -i /tmp/*.deb; apt-get -yf install + +### END CUSTOM STUFF ### + +RUN chown -R 1000:0 $HOME +USER 1000:ssl-cert +WORKDIR $HOME + +ENTRYPOINT [ "/dockerstartup/vnc_startup.sh" ] diff --git a/builder/dockerfile.ubuntu_bionic.deb.build b/builder/dockerfile.ubuntu_bionic.deb.build index ac48856..a554ecb 100644 --- a/builder/dockerfile.ubuntu_bionic.deb.build +++ b/builder/dockerfile.ubuntu_bionic.deb.build @@ -7,4 +7,11 @@ RUN apt-get update && \ COPY ./debian/control /tmp RUN apt-get update && echo YYY | mk-build-deps --install --remove /tmp/control -USER 1000 +ARG L_UID +RUN if [ "$L_UID" -eq 0 ]; then \ + useradd -m docker; \ + else \ + useradd -m docker -u $L_UID;\ + fi + +USER docker diff --git a/builder/dockerfile.ubuntu_bionic.deb.test b/builder/dockerfile.ubuntu_bionic.deb.test index 793c2ca..7230475 100644 --- a/builder/dockerfile.ubuntu_bionic.deb.test +++ b/builder/dockerfile.ubuntu_bionic.deb.test @@ -42,8 +42,8 @@ COPY startup/ $STARTUPDIR ### START CUSTOM STUFF #### ARG KASMVNC_PACKAGE_DIR -COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp -RUN dpkg -i /tmp/*.deb; apt-get -yf install +COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp/ +RUN rm -f /tmp/kasmvncserver_*+*.deb; dpkg -i /tmp/*.deb; apt-get -yf install ### END CUSTOM STUFF ### diff --git a/builder/dockerfile.ubuntu_focal.barebones.deb.test b/builder/dockerfile.ubuntu_focal.barebones.deb.test index 26b0c14..ae046ad 100644 --- a/builder/dockerfile.ubuntu_focal.barebones.deb.test +++ b/builder/dockerfile.ubuntu_focal.barebones.deb.test @@ -1,8 +1,8 @@ FROM ubuntu:focal ARG KASMVNC_PACKAGE_DIR -COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp -RUN apt-get update && dpkg -i /tmp/*.deb; apt-get -yf install +COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp/ +RUN rm -f /tmp/kasmvncserver_*+*.deb; apt-get update && dpkg -i /tmp/*.deb; apt-get -yf install RUN apt-get update && apt-get -y install xterm lsb-release RUN useradd -m foo && addgroup foo ssl-cert diff --git a/builder/dockerfile.ubuntu_focal.deb.build b/builder/dockerfile.ubuntu_focal.deb.build index 619a93d..8a4db12 100644 --- a/builder/dockerfile.ubuntu_focal.deb.build +++ b/builder/dockerfile.ubuntu_focal.deb.build @@ -9,4 +9,11 @@ RUN apt-get update && \ COPY ./debian/control /tmp RUN apt-get update && echo YYY | mk-build-deps --install --remove /tmp/control -USER 1000 +ARG L_UID +RUN if [ "$L_UID" -eq 0 ]; then \ + useradd -m docker; \ + else \ + useradd -m docker -u $L_UID;\ + fi + +USER docker diff --git a/builder/dockerfile.ubuntu_focal.deb.test b/builder/dockerfile.ubuntu_focal.deb.test index 3397848..867dbd7 100644 --- a/builder/dockerfile.ubuntu_focal.deb.test +++ b/builder/dockerfile.ubuntu_focal.deb.test @@ -42,8 +42,8 @@ COPY startup/ $STARTUPDIR ### START CUSTOM STUFF #### ARG KASMVNC_PACKAGE_DIR -COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp -RUN dpkg -i /tmp/*.deb; apt-get -yf install +COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp/ +RUN rm -f /tmp/kasmvncserver_*+*.deb; dpkg -i /tmp/*.deb; apt-get -yf install RUN mkdir ~/.vnc && echo '/usr/bin/xfce4-session &' >> ~/.vnc/xstartup && \ chmod +x ~/.vnc/xstartup diff --git a/builder/os_ver_cli.sh b/builder/os_ver_cli.sh index e1e230f..9dc4f80 100644 --- a/builder/os_ver_cli.sh +++ b/builder/os_ver_cli.sh @@ -3,6 +3,11 @@ default_os_codename=bionic os=${1:-$default_os} os_codename=${2:-$default_os_codename} +build_tag="${3:-}" +if [[ -n "$build_tag" ]]; then + build_tag_for_images="_${build_tag#+}" + build_debian_revision="$(echo $build_tag | tr _ -)" +fi os_image="$os:$os_codename" echo "Building for $os_image" diff --git a/builder/test-deb b/builder/test-deb index 9114a3e..fa135d9 100755 --- a/builder/test-deb +++ b/builder/test-deb @@ -5,10 +5,12 @@ set -e cd "$(dirname "$0")" . ./os_ver_cli.sh +tester_image=kasmvnctester_${os}:$os_codename${build_tag_for_images} docker build --build-arg KASMVNC_PACKAGE_DIR="build/${os_codename}" \ - -t kasmvnctester_${os}:$os_codename \ - -f dockerfile.${os}_${os_codename}.deb.test . + --build-arg BUILD_DEBIAN_REVISION="$build_debian_revision" \ + -t "$tester_image" \ + -f dockerfile.${os}_${os_codename}${build_tag}.deb.test . docker run -it -p 443:8443 --rm \ -e KASMVNC_VERBOSE_LOGGING=$KASMVNC_VERBOSE_LOGGING \ -e "VNC_USER=foo" -e "VNC_PW=foobar" \ - kasmvnctester_${os}:$os_codename + "$tester_image" diff --git a/debian/Makefile.to_fakebuild_tar_package b/debian/Makefile.to_fakebuild_tar_package index dd097af..4a0938d 100644 --- a/debian/Makefile.to_fakebuild_tar_package +++ b/debian/Makefile.to_fakebuild_tar_package @@ -1,7 +1,7 @@ TARGET_OS := $(shell lsb_release -is | tr '[:upper:]' '[:lower:]') TARGET_OS_CODENAME := $(shell lsb_release -cs | tr '[:upper:]' '[:lower:]') TARBALL_DIR := builder/build -TARBALL := $(TARBALL_DIR)/kasmvnc.$(TARGET_OS)_$(TARGET_OS_CODENAME).tar.gz +TARBALL := $(TARBALL_DIR)/kasmvnc.$(TARGET_OS)_$(TARGET_OS_CODENAME)$(BUILD_TAG).tar.gz TAR_DATA := $(shell mktemp -d) SRC := $(TAR_DATA)/usr/local SRC_BIN := $(SRC)/bin