Split the prebuilt-image recipe out of new_docker_build.sh into a Dockerfile

- Dockerfile: the prebuilt build image recipe (Ubuntu 26.04 + apt deps +
  aqtinstall Qt6 + KDReports), parameterized via ARG APT_PACKAGES /
  QT_VERSION / QT_ARCH / QT_BASE_DIR.
- new_docker_build.sh: build_prebuilt_image() now runs
  docker build -f Dockerfile with the package list and Qt settings passed
  as build args, using an empty build context (the Dockerfile has no
  COPY/ADD).
This commit is contained in:
berrux-dev committed 2026-10-13 21:47:38 +02:00
1 parent 23cf641d36
commit 65ca0d8b5e
2 files changed
+71 -48

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
# Prebuilt build image for the release validation-scope branch
# (Ubuntu 26.04 + Qt6 + all dependencies for the legatus release build).
#
# Built by new_docker_build.sh --build-prebuilt-image, which passes the
# package list and Qt settings as build args (see build_prebuilt_image()).
FROM ubuntu:26.04
ENV DEBIAN_FRONTEND=noninteractive
ARG APT_PACKAGES
ARG QT_VERSION=6.10.2
ARG QT_ARCH=linux_gcc_64
ARG QT_BASE_DIR=/opt/Qt
RUN apt-get update -qq && \
apt-get install -y -qq \
${APT_PACKAGES} \
libqt6svg6-dev \
libgtest-dev \
libgmock-dev \
python3-pip && \
rm -rf /var/lib/apt/lists/*
# Install Qt6 packages via aqtinstall
# Note: QtWebKit is deprecated in Qt6, use QtWebEngine instead
# KDReports is installed via aqtinstall or built from source if needed
# Note: qtsvg is NOT available via aqtinstall - it's provided by libqt6svg6-dev apt package
RUN pip3 install --break-system-packages --quiet aqtinstall && \
aqt install-qt linux desktop ${QT_VERSION} ${QT_ARCH} \
-m qtmultimedia qtserialport qtimageformats qtwebsockets qtwebengine \
qtpdf qtwebview qt5compat qtwebchannel qtpositioning qtlocation qtsensors \
--outputdir ${QT_BASE_DIR} && \
rm -rf /root/.cache/Aqt
# Install KDReports from source (apt package not available in Ubuntu 22.04/26.04)
# Try apt install first (will fail), then build from KDAB GitHub mirror
RUN apt-get install -y -qq libkdreports-dev 2>/dev/null || \
(git clone --depth 1 https://github.com/KDAB/KDReports.git /tmp/KDReports && \
cd /tmp/KDReports && \
mkdir build && cd build && \
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_PREFIX_PATH=${QT_BASE_DIR} .. && \
make -j$(nproc) && \
make install && \
cd / && rm -rf /tmp/KDReports)
# Legacy sources include <KDReports/...> but the Qt6 package installs headers flat
# under /usr/local/include/KDReports-qt6 - alias the directory so the prefixed
# includes resolve through the default /usr/local/include search path.
RUN ln -sfn KDReports-qt6 /usr/local/include/KDReports
CMD ["/bin/bash"]
@@ -12,6 +12,8 @@ set -euo pipefail
# - Validates MIGRATE_PIPELINE_ROOT and rti_license.dat
# - Optional usage of a prebuilt Docker image with installed dependencies
# - Optional creation of that prebuilt Docker image via --build-prebuilt-image
# (Dockerfile lives next to this script; the package list and Qt settings
# are passed as build args)
# - Optional deletion of that prebuilt Docker image via --delete-prebuilt-image
# - Optional Jenkins builder run for RPM/DEB package production
# - Uses a temporary container-side script for robust execution
@@ -30,8 +32,9 @@ Options:
--no-prebuilt-image Use base image and run apt-get install inside the container
--docker-image IMAGE Docker image name to use/build/delete
(default: legatus-qt6-prebuilt:latest)
--build-prebuilt-image Build the prebuilt Docker image before running the build
If used alone, the script builds the image and exits
--build-prebuilt-image Build the prebuilt Docker image (from ./Dockerfile)
before running the build. If used alone, the script
builds the image and exits
If combined with --use-prebuilt-image, the built image is used immediately
--delete-prebuilt-image Delete the configured Docker image and exit
--cmake_build_flags FLAGS Extra CMake flags passed to the in-container configure
@@ -236,57 +239,25 @@ APT_PACKAGES_STRING="$(join_by ' ' "${APT_PACKAGES[@]}")"
build_prebuilt_image() {
local image_name="$1"
local dockerfile="Dockerfile"
require_file "${dockerfile}" "Prebuilt-image Dockerfile"
# The Dockerfile has no COPY/ADD, so an empty build context is fine -
# this avoids tarring the source tree into the build context.
local tmp_dir
tmp_dir="$(mktemp -d)"
trap 'cleanup_temp_dir "$tmp_dir"' RETURN
cat > "${tmp_dir}/Dockerfile" <<EOF
FROM ubuntu:26.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq && \
apt-get install -y -qq \
${APT_PACKAGES_STRING} \
libqt6svg6-dev \
libgtest-dev \
libgmock-dev \
python3-pip && \
rm -rf /var/lib/apt/lists/*
# Install Qt6 packages via aqtinstall
# Note: QtWebKit is deprecated in Qt6, use QtWebEngine instead
# KDReports is installed via aqtinstall or built from source if needed
# Note: qtsvg is NOT available via aqtinstall - it's provided by libqt6svg6-dev apt package
RUN pip3 install --break-system-packages --quiet aqtinstall && \
aqt install-qt linux desktop ${QT_VERSION} ${QT_ARCH} \
-m qtmultimedia qtserialport qtimageformats qtwebsockets qtwebengine \
qtpdf qtwebview qt5compat qtwebchannel qtpositioning qtlocation qtsensors \
--outputdir ${QT_BASE_DIR} && \
rm -rf /root/.cache/Aqt
# Install KDReports from source (apt package not available in Ubuntu 22.04/26.04)
# Try apt install first (will fail), then build from KDAB GitHub mirror
RUN apt-get install -y -qq libkdreports-dev 2>/dev/null || \
(git clone --depth 1 https://github.com/KDAB/KDReports.git /tmp/KDReports && \
cd /tmp/KDReports && \
mkdir build && cd build && \
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_PREFIX_PATH=${QT_BASE_DIR} .. && \
make -j$(nproc) && \
make install && \
cd / && rm -rf /tmp/KDReports)
# Legacy sources include <KDReports/...> but the Qt6 package installs headers flat
# under /usr/local/include/KDReports-qt6 - alias the directory so the prefixed
# includes resolve through the default /usr/local/include search path.
RUN ln -sfn KDReports-qt6 /usr/local/include/KDReports
CMD ["/bin/bash"]
EOF
log_info "Building prebuilt Docker image: ${image_name}"
docker build -t "${image_name}" "${tmp_dir}"
log_info "Building prebuilt Docker image: ${image_name} (Dockerfile: ${dockerfile})"
docker build -t "${image_name}" \
-f "${dockerfile}" \
--build-arg APT_PACKAGES="${APT_PACKAGES_STRING}" \
--build-arg QT_VERSION="${QT_VERSION}" \
--build-arg QT_ARCH="${QT_ARCH}" \
--build-arg QT_BASE_DIR="${QT_BASE_DIR}" \
"${tmp_dir}"
log_info "Prebuilt Docker image created successfully: ${image_name}"
}