diff --git a/docker/build_images.sh b/docker/build_images.sh index b4983d5b2..20b8d84f9 100755 --- a/docker/build_images.sh +++ b/docker/build_images.sh @@ -3,8 +3,11 @@ # # Each docker//Dockerfile is a *self-contained build environment* (toolchain, static Qt, # static libdbus, static OpenSSL, Eigen, DIALS, XDS, Node, ...). It does NOT copy the project in -- -# the source is mounted and built at run time (see build_in_rocky9.sh). So the build context is just -# the per-variant directory; the huge repo is never sent to the Docker daemon. +# the source is mounted and built at run time (see build_in_rocky9.sh). +# +# The build context is docker/ rather than docker//, because every variant COPYs the +# shared steps in docker/common/ (see common/README.md). That context is still only the Dockerfiles +# and those scripts; the huge repo is never sent to the Docker daemon. # # Images are tagged gitea.psi.ch/leonarski_f/jfjoch_: (matches the CI runner images). # @@ -23,9 +26,9 @@ # TAG=2607b docker/build_images.sh # override the tag (default 2607b) # # The tag has to match what .gitea/workflows/build_and_test.yml asks the runner for, or CI pulls a -# different image than the one just built. Currently jfjoch_rocky8:2511 and jfjoch_ubuntu2404:2508 -- -# ubuntu2404 being the image that also carries the aarch64 cross toolchain, so: -# TAG=2508 docker/build_images.sh ubuntu2404 +# different image than the one just built. Every job there now names its image explicitly: +# the rockys on 2607b, the ubuntus on 2608b. Build a single variant with, e.g.: +# TAG=2608b docker/build_images.sh ubuntu2404 # PUSH=1 docker/build_images.sh # build (parallel) then push (serial; needs docker login) # # Parallel stdout would be an unreadable interleave, so each build streams to its own log file: @@ -54,7 +57,7 @@ build_one() { local v="$1" local img="$REGISTRY/jfjoch_$v:$TAG" local log="$logdir/${v}-${TAG}.log" - if docker build --pull -t "$img" "$here/$v" >"$log" 2>&1; then + if docker build --pull -t "$img" -f "$here/$v/Dockerfile" "$here" >"$log" 2>&1; then echo OK > "$logdir/${v}-${TAG}.status" else echo FAIL > "$logdir/${v}-${TAG}.status" diff --git a/docker/common/README.md b/docker/common/README.md new file mode 100644 index 000000000..736a848ce --- /dev/null +++ b/docker/common/README.md @@ -0,0 +1,21 @@ +# Shared build-image steps + +`docker/rocky8`, `docker/rocky9`, `docker/ubuntu2204` and `docker/ubuntu2404` differ only in their +package manager, their package list and a few distro-specific extras (DIALS and XDS on rocky9, the +aarch64 cross toolchain on ubuntu2404, the release tooling on rocky8). Everything built from +source is identical in all four, so it lives here and is run by each Dockerfile in this order: + +| script | what it installs | +|---|---| +| `install-cmake.sh` | CMake, pinned, from cmake.org -- the distro CMake is not used | +| `build-openssl.sh` | static OpenSSL into `/opt/openssl-$OPENSSL_VERSION` | +| `build-dbus.sh` | static libdbus into `/opt/dbus-$DBUS_VERSION-static` | +| `build-qt.sh` | static Qt 6 into `$QT_PREFIX` | +| `install-eigen.sh` | Eigen 3.4 into `/opt/eigen-3.4` | + +They read their versions from the ARGs of the Dockerfile that runs them, and each one is the +verbatim shell that used to be inlined four times. Keeping one copy is the point: the HTTP/1.1 git +fix once landed in the two Ubuntu images and neither Rocky one, because there were four copies to +remember. + +The build context is therefore `docker/`, not `docker//` -- see `build_images.sh`. diff --git a/docker/common/build-dbus.sh b/docker/common/build-dbus.sh new file mode 100755 index 000000000..481e52609 --- /dev/null +++ b/docker/common/build-dbus.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# Static libdbus, so the viewer links D-Bus in rather than pulling libdbus-1.so.3 -- and with it +# libsystemd and libselinux -- at runtime. The viewer is a pure session-bus client, so the daemon-side +# systemd/selinux features are off; built -fPIC so the archive links into Qt's PIE tools. +# +# Shared by all four build images (docker/*/Dockerfile). The build context is docker/, so each +# Dockerfile reaches this with COPY common/. Version inputs come from that Dockerfile's ARGs. + +set -eux; \ + cd /tmp; \ + curl -LO https://dbus.freedesktop.org/releases/dbus/dbus-${DBUS_VERSION}.tar.xz; \ + tar -xf dbus-${DBUS_VERSION}.tar.xz; \ + cd dbus-${DBUS_VERSION}; \ + ./configure --prefix=/opt/dbus-${DBUS_VERSION}-static \ + --enable-static --disable-shared --with-pic \ + --disable-systemd --without-systemdsystemunitdir \ + --disable-selinux --disable-apparmor --disable-libaudit \ + --disable-tests --disable-asserts \ + --disable-doxygen-docs --disable-xml-docs --disable-ducktype-docs \ + CFLAGS="-fPIC"; \ + make -j"$(nproc)"; \ + make install; \ + cd /; rm -rf /tmp/dbus-${DBUS_VERSION} /tmp/dbus-${DBUS_VERSION}.tar.xz diff --git a/docker/common/build-openssl.sh b/docker/common/build-openssl.sh new file mode 100755 index 000000000..756114d12 --- /dev/null +++ b/docker/common/build-openssl.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# Static OpenSSL into /opt/openssl-$OPENSSL_VERSION. +# +# Shared by all four build images (docker/*/Dockerfile). The build context is docker/, so each +# Dockerfile reaches this with COPY common/. Version inputs come from that Dockerfile's ARGs. + +set -eux; \ + cd /tmp; \ + curl -LO https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz; \ + tar -xf openssl-${OPENSSL_VERSION}.tar.gz; \ + cd openssl-${OPENSSL_VERSION}; \ + ./Configure linux-x86_64 no-shared no-module no-tests --prefix=/opt/openssl-${OPENSSL_VERSION} --libdir=lib; \ + make -j"$(nproc)"; \ + make install_sw; \ + cd /; rm -rf /tmp/openssl-${OPENSSL_VERSION} /tmp/openssl-${OPENSSL_VERSION}.tar.gz diff --git a/docker/common/build-qt.sh b/docker/common/build-qt.sh new file mode 100755 index 000000000..ed0ab0e8d --- /dev/null +++ b/docker/common/build-qt.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +# Static Qt 6 (Core, Gui, Widgets, Charts, DBus) into $QT_PREFIX. +# +# Shared by all four build images (docker/*/Dockerfile). The build context is docker/, so each +# Dockerfile reaches this with COPY common/. Version inputs come from that Dockerfile's ARGs. + +set -eux + +# The download path carries the SERIES (6.11), the tarball the full version (6.11.1); deriving one +# from the other is what stops a version bump from silently 404ing on the old series directory. +QT_SERIES=${QT_VERSION%.*} + +set -eux; \ + cd /tmp; \ + curl -LO https://download.qt.io/official_releases/qt/${QT_SERIES}/${QT_VERSION}/single/qt-everywhere-src-${QT_VERSION}.tar.xz; \ + tar -xf qt-everywhere-src-${QT_VERSION}.tar.xz; \ + mkdir -p qt-everywhere-src-${QT_VERSION}/build && cd qt-everywhere-src-${QT_VERSION}/build; \ + cmake -G Ninja \ + -DQT_BUILD_SUBMODULES="qtbase;qtshadertools;qtdeclarative;qtcharts;qt3d" \ + -DBUILD_SHARED_LIBS=OFF \ + -DQT_BUILD_TESTS=OFF \ + -DQT_BUILD_EXAMPLES=OFF \ + -DQT_FEATURE_dbus=ON \ + -DQT_FEATURE_dbus_linked=ON \ + -DDBus1_DIR=/opt/dbus-${DBUS_VERSION}-static/lib/cmake/DBus1 \ + -DQT_FEATURE_xcb=ON \ + -DQT_FEATURE_xcb_xlib=OFF \ + -DQT_FEATURE_xkbcommon_x11=ON \ + -DQT_FEATURE_opengl=ON \ + -DQT_FEATURE_opengl_desktop=ON \ + -DQT_FEATURE_opengl_dynamic=OFF \ + -DQT_FEATURE_vulkan=OFF \ + -DQT_FEATURE_glib=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=${QT_PREFIX} \ + -DCMAKE_C_COMPILER=${CC} \ + -DCMAKE_CXX_COMPILER=${CXX} \ + -DQT_FEATURE_openssl=ON \ + -DQT_FEATURE_openssl_linked=ON \ + -DOPENSSL_USE_STATIC_LIBS=TRUE \ + ..; \ + cmake --build . -j"$(nproc)"; \ + cmake --install .; \ + cd /; rm -rf /tmp/qt-everywhere-src-${QT_VERSION} /tmp/qt-everywhere-src-${QT_VERSION}.tar.xz diff --git a/docker/common/install-cmake.sh b/docker/common/install-cmake.sh new file mode 100755 index 000000000..efca13b61 --- /dev/null +++ b/docker/common/install-cmake.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# CMake, pinned, from Kitware's own download host. +# +# Shared by all four build images (docker/*/Dockerfile). The build context is docker/, so each +# Dockerfile reaches this with COPY common/. Version inputs come from that Dockerfile's ARGs. +# +# The distro CMake is deliberately NOT installed: the four base images ship three different +# versions (EL8 3.26.5, EL9 3.31.8, Jammy 3.22, Noble 3.28.3), and they move under us at every +# base-image refresh. That spread is what makes a configure fail on one image and pass on the +# next -- policy defaults and FetchContent behaviour both depend on it. One pinned CMake +# everywhere removes the whole class of problem, and it is the only such tool the build cannot +# pin from inside the repository. +# +# cmake.org rather than the GitHub release asset: the images already fetch everything else from +# GitHub, and GitHub throttles unauthenticated downloads by TLS fingerprint. +set -eux + +: "${CMAKE_VERSION:?set CMAKE_VERSION}" +: "${CMAKE_SHA256:?set CMAKE_SHA256}" + +series=${CMAKE_VERSION%.*} +tarball=cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz + +cd /tmp +curl -fLO "https://cmake.org/files/v${series}/${tarball}" +echo "${CMAKE_SHA256} ${tarball}" | sha256sum -c - +mkdir -p "/opt/cmake-${CMAKE_VERSION}" +tar -xzf "${tarball}" -C "/opt/cmake-${CMAKE_VERSION}" --strip-components=1 +rm -f "${tarball}" + +# The Dockerfile puts /opt/cmake-$CMAKE_VERSION/bin on PATH; check the pin took. +test "$("/opt/cmake-${CMAKE_VERSION}/bin/cmake" --version | head -1)" = "cmake version ${CMAKE_VERSION}" diff --git a/docker/common/install-eigen.sh b/docker/common/install-eigen.sh new file mode 100755 index 000000000..e0d3d512f --- /dev/null +++ b/docker/common/install-eigen.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# Eigen, the external find_package(Eigen3 3.4) dependency, into /opt/eigen-3.4. Header-only; +# 3.4.x is required because Eigen's same-major-version rule rejects 5.x. +# +# Shared by all four build images (docker/*/Dockerfile). The build context is docker/, so each +# Dockerfile reaches this with COPY common/. Version inputs come from that Dockerfile's ARGs. + +set -eux; \ + cd /tmp; \ + git clone --depth 1 --branch ${EIGEN_VERSION} https://gitlab.com/libeigen/eigen.git; \ + cmake -G Ninja -S eigen -B eigen-build -DCMAKE_INSTALL_PREFIX=/opt/eigen-3.4 \ + -DEIGEN_BUILD_BLAS=OFF -DEIGEN_BUILD_LAPACK=OFF -DEIGEN_BUILD_DOC=OFF -DBUILD_TESTING=OFF; \ + cmake --install eigen-build; \ + cd /; rm -rf /tmp/eigen /tmp/eigen-build diff --git a/docker/rocky8/Dockerfile b/docker/rocky8/Dockerfile index f3db6b7ff..4099b709a 100644 --- a/docker/rocky8/Dockerfile +++ b/docker/rocky8/Dockerfile @@ -22,7 +22,6 @@ RUN dnf -y install epel-release && \ tar \ xz \ make \ - cmake \ nasm \ gcc-toolset-13 \ gcc-toolset-13-gcc \ @@ -51,7 +50,6 @@ RUN dnf -y install epel-release && \ expat-devel \ krb5-devel \ zlib-devel \ - zlib-static \ fontconfig-devel \ zlib-static \ java-21-openjdk-headless \ @@ -69,15 +67,17 @@ RUN dnf -y install epel-release && \ freetype-devel && \ dnf clean all && rm -rf /var/cache/dnf -RUN set -eux; \ - cd /tmp; \ - curl -LO https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz; \ - tar -xf openssl-${OPENSSL_VERSION}.tar.gz; \ - cd openssl-${OPENSSL_VERSION}; \ - ./Configure linux-x86_64 no-shared no-module no-tests --prefix=/opt/openssl-${OPENSSL_VERSION} --libdir=lib; \ - make -j"$(nproc)"; \ - make install_sw; \ - cd /; rm -rf /tmp/openssl-${OPENSSL_VERSION} /tmp/openssl-${OPENSSL_VERSION}.tar.gz +# Everything built from source below is identical in all four build images, so it lives in +# docker/common/ and is run from there -- one copy to change, not four. The build context is +# docker/ (see build_images.sh), which is what puts common/ in reach of this COPY. +ARG CMAKE_VERSION=3.31.8 +ARG CMAKE_SHA256=630615d8e98ac33eba7fbe472626dff5c899c85af3c024585ae109166a6909d0 +COPY common/ /opt/jfjoch-common/ +RUN /opt/jfjoch-common/install-cmake.sh +# Ahead of the distro path: the pinned CMake is the one every later step and every CI build uses. +ENV PATH=/opt/cmake-${CMAKE_VERSION}/bin:${PATH} + +RUN /opt/jfjoch-common/build-openssl.sh # Expose static OpenSSL to CMake/pkg-config ENV OPENSSL_ROOT_DIR=/opt/openssl-${OPENSSL_VERSION} @@ -106,67 +106,16 @@ ENV PKG_CONFIG_PATH=${OPENSSL_ROOT_DIR}/lib/pkgconfig:${OPENSSL_ROOT_DIR}/lib64/ # installs, which imports libdbus-1.a). Built -fPIC (--with-pic) so the archive links into Qt's PIE # tools (qdbusxml2cpp). expat is only a configure-time dep of the dbus daemon; the client libdbus-1 # links neither expat nor systemd. -RUN set -eux; \ - cd /tmp; \ - curl -LO https://dbus.freedesktop.org/releases/dbus/dbus-${DBUS_VERSION}.tar.xz; \ - tar -xf dbus-${DBUS_VERSION}.tar.xz; \ - cd dbus-${DBUS_VERSION}; \ - ./configure --prefix=/opt/dbus-${DBUS_VERSION}-static \ - --enable-static --disable-shared --with-pic \ - --disable-systemd --without-systemdsystemunitdir \ - --disable-selinux --disable-apparmor --disable-libaudit \ - --disable-tests --disable-asserts \ - --disable-doxygen-docs --disable-xml-docs --disable-ducktype-docs \ - CFLAGS="-fPIC"; \ - make -j"$(nproc)"; \ - make install; \ - cd /; rm -rf /tmp/dbus-${DBUS_VERSION} /tmp/dbus-${DBUS_VERSION}.tar.xz +RUN /opt/jfjoch-common/build-dbus.sh # Put the static libdbus pkgconfig ahead of the system one so Qt6::DBus resolves to the .a ENV PKG_CONFIG_PATH=/opt/dbus-${DBUS_VERSION}-static/lib/pkgconfig:${PKG_CONFIG_PATH} ARG QT_PREFIX=/opt/qt-${QT_VERSION}-static -RUN set -eux; \ - cd /tmp; \ - curl -LO https://download.qt.io/official_releases/qt/6.9/${QT_VERSION}/single/qt-everywhere-src-${QT_VERSION}.tar.xz; \ - tar -xf qt-everywhere-src-${QT_VERSION}.tar.xz; \ - mkdir -p qt-everywhere-src-${QT_VERSION}/build && cd qt-everywhere-src-${QT_VERSION}/build; \ - cmake -G Ninja \ - -DQT_BUILD_SUBMODULES="qtbase;qtshadertools;qtdeclarative;qtcharts;qt3d" \ - -DBUILD_SHARED_LIBS=OFF \ - -DQT_BUILD_TESTS=OFF \ - -DQT_BUILD_EXAMPLES=OFF \ - -DQT_FEATURE_dbus=ON \ - -DQT_FEATURE_dbus_linked=ON \ - -DDBus1_DIR=/opt/dbus-${DBUS_VERSION}-static/lib/cmake/DBus1 \ - -DQT_FEATURE_xcb=ON \ - -DQT_FEATURE_xcb_xlib=OFF \ - -DQT_FEATURE_xkbcommon_x11=ON \ - -DQT_FEATURE_opengl=ON \ - -DQT_FEATURE_opengl_desktop=ON \ - -DQT_FEATURE_opengl_dynamic=OFF \ - -DQT_FEATURE_vulkan=OFF \ - -DQT_FEATURE_glib=OFF \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX=${QT_PREFIX} \ - -DCMAKE_C_COMPILER=${CC} \ - -DCMAKE_CXX_COMPILER=${CXX} \ - -DQT_FEATURE_openssl=ON \ - -DQT_FEATURE_openssl_linked=ON \ - -DOPENSSL_USE_STATIC_LIBS=TRUE \ - ..; \ - cmake --build . -j"$(nproc)"; \ - cmake --install .; \ - cd /; rm -rf /tmp/qt-everywhere-src-${QT_VERSION} /tmp/qt-everywhere-src-${QT_VERSION}.tar.xz +RUN /opt/jfjoch-common/build-qt.sh # Eigen 3.4 (header-only) -- external find_package(Eigen3 3.4) dependency, installed to /opt/eigen-3.4. -RUN set -eux; \ - cd /tmp; \ - git clone --depth 1 --branch ${EIGEN_VERSION} https://gitlab.com/libeigen/eigen.git; \ - cmake -G Ninja -S eigen -B eigen-build -DCMAKE_INSTALL_PREFIX=/opt/eigen-3.4 \ - -DEIGEN_BUILD_BLAS=OFF -DEIGEN_BUILD_LAPACK=OFF -DEIGEN_BUILD_DOC=OFF -DBUILD_TESTING=OFF; \ - cmake --install eigen-build; \ - cd /; rm -rf /tmp/eigen /tmp/eigen-build +RUN /opt/jfjoch-common/install-eigen.sh # Make Qt, the static libdbus, and Eigen discoverable by CMake. The static libdbus prefix is # required here (not only at Qt build time): every Qt6::DBus consumer re-runs find_package(DBus1) @@ -178,3 +127,5 @@ WORKDIR /workspace # Default entrypoint prints tool versions and hints. CMD ["/bin/bash", "-l"] + +RUN rm -rf /opt/jfjoch-common diff --git a/docker/rocky9/Dockerfile b/docker/rocky9/Dockerfile index 57a513f8b..cf9a3202e 100644 --- a/docker/rocky9/Dockerfile +++ b/docker/rocky9/Dockerfile @@ -28,7 +28,6 @@ RUN dnf -y update && \ tar \ xz \ make \ - cmake \ gcc-toolset-13 \ gcc-toolset-13-gcc \ gcc-toolset-13-gcc-c++ \ @@ -43,7 +42,6 @@ RUN dnf -y update && \ perl \ nasm \ pkgconf-pkg-config \ - libxcb-devel \ xcb-util-*-devel \ libxcb-devel \ libxkbcommon-devel \ @@ -62,7 +60,6 @@ RUN dnf -y update && \ krb5-devel \ zlib-devel \ zlib-static \ - zlib-static \ fontconfig-devel \ mesa-dri-drivers \ libdrm-devel \ @@ -73,15 +70,17 @@ RUN dnf -y update && \ freetype-devel && \ dnf clean all && rm -rf /var/cache/dnf -RUN set -eux; \ - cd /tmp; \ - curl -LO https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz; \ - tar -xf openssl-${OPENSSL_VERSION}.tar.gz; \ - cd openssl-${OPENSSL_VERSION}; \ - ./Configure linux-x86_64 no-shared no-module no-tests --prefix=/opt/openssl-${OPENSSL_VERSION} --libdir=lib; \ - make -j"$(nproc)"; \ - make install_sw; \ - cd /; rm -rf /tmp/openssl-${OPENSSL_VERSION} /tmp/openssl-${OPENSSL_VERSION}.tar.gz +# Everything built from source below is identical in all four build images, so it lives in +# docker/common/ and is run from there -- one copy to change, not four. The build context is +# docker/ (see build_images.sh), which is what puts common/ in reach of this COPY. +ARG CMAKE_VERSION=3.31.8 +ARG CMAKE_SHA256=630615d8e98ac33eba7fbe472626dff5c899c85af3c024585ae109166a6909d0 +COPY common/ /opt/jfjoch-common/ +RUN /opt/jfjoch-common/install-cmake.sh +# Ahead of the distro path: the pinned CMake is the one every later step and every CI build uses. +ENV PATH=/opt/cmake-${CMAKE_VERSION}/bin:${PATH} + +RUN /opt/jfjoch-common/build-openssl.sh # Expose static OpenSSL to CMake/pkg-config ENV OPENSSL_ROOT_DIR=/opt/openssl-${OPENSSL_VERSION} @@ -109,59 +108,14 @@ ENV CXX=${GCC_TOOLSET_ROOT}/usr/bin/g++ # installs, which imports libdbus-1.a). Built -fPIC (--with-pic) so the archive links into Qt's PIE # tools (qdbusxml2cpp). expat is only a configure-time dep of the dbus daemon; the client libdbus-1 # links neither expat nor systemd. -RUN set -eux; \ - cd /tmp; \ - curl -LO https://dbus.freedesktop.org/releases/dbus/dbus-${DBUS_VERSION}.tar.xz; \ - tar -xf dbus-${DBUS_VERSION}.tar.xz; \ - cd dbus-${DBUS_VERSION}; \ - ./configure --prefix=/opt/dbus-${DBUS_VERSION}-static \ - --enable-static --disable-shared --with-pic \ - --disable-systemd --without-systemdsystemunitdir \ - --disable-selinux --disable-apparmor --disable-libaudit \ - --disable-tests --disable-asserts \ - --disable-doxygen-docs --disable-xml-docs --disable-ducktype-docs \ - CFLAGS="-fPIC"; \ - make -j"$(nproc)"; \ - make install; \ - cd /; rm -rf /tmp/dbus-${DBUS_VERSION} /tmp/dbus-${DBUS_VERSION}.tar.xz +RUN /opt/jfjoch-common/build-dbus.sh # Put the static libdbus pkgconfig ahead of the system one so Qt6::DBus resolves to the .a ENV PKG_CONFIG_PATH=/opt/dbus-${DBUS_VERSION}-static/lib/pkgconfig:${PKG_CONFIG_PATH} # Build and install static Qt 6.9 with Core, Gui, Widgets, Charts, DBus ARG QT_PREFIX=/opt/qt-${QT_VERSION}-static -RUN set -eux; \ - cd /tmp; \ - curl -LO https://download.qt.io/official_releases/qt/6.9/${QT_VERSION}/single/qt-everywhere-src-${QT_VERSION}.tar.xz; \ - tar -xf qt-everywhere-src-${QT_VERSION}.tar.xz; \ - mkdir -p qt-everywhere-src-${QT_VERSION}/build && cd qt-everywhere-src-${QT_VERSION}/build; \ - cmake -G Ninja \ - -DQT_BUILD_SUBMODULES="qtbase;qtshadertools;qtdeclarative;qtcharts;qt3d" \ - -DBUILD_SHARED_LIBS=OFF \ - -DQT_BUILD_TESTS=OFF \ - -DQT_BUILD_EXAMPLES=OFF \ - -DQT_FEATURE_dbus=ON \ - -DQT_FEATURE_dbus_linked=ON \ - -DDBus1_DIR=/opt/dbus-${DBUS_VERSION}-static/lib/cmake/DBus1 \ - -DQT_FEATURE_xcb=ON \ - -DQT_FEATURE_xcb_xlib=OFF \ - -DQT_FEATURE_xkbcommon_x11=ON \ - -DQT_FEATURE_opengl=ON \ - -DQT_FEATURE_opengl_desktop=ON \ - -DQT_FEATURE_opengl_dynamic=OFF \ - -DQT_FEATURE_vulkan=OFF \ - -DQT_FEATURE_glib=OFF \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX=${QT_PREFIX} \ - -DCMAKE_C_COMPILER=${CC} \ - -DCMAKE_CXX_COMPILER=${CXX} \ - -DQT_FEATURE_openssl=ON \ - -DQT_FEATURE_openssl_linked=ON \ - -DOPENSSL_USE_STATIC_LIBS=TRUE \ - ..; \ - cmake --build . -j"$(nproc)"; \ - cmake --install .; \ - cd /; rm -rf /tmp/qt-everywhere-src-${QT_VERSION} /tmp/qt-everywhere-src-${QT_VERSION}.tar.xz +RUN /opt/jfjoch-common/build-qt.sh # Install DIALS using the official binary tarball workflow RUN set -eux; \ @@ -199,13 +153,7 @@ RUN set -eux; \ https://gitea.psi.ch/mx/durin/releases/download/1.0.0/libdurin-plugin.so.1.0.0 # Eigen 3.4 (header-only) -- external find_package(Eigen3 3.4) dependency, installed to /opt/eigen-3.4. -RUN set -eux; \ - cd /tmp; \ - git clone --depth 1 --branch ${EIGEN_VERSION} https://gitlab.com/libeigen/eigen.git; \ - cmake -G Ninja -S eigen -B eigen-build -DCMAKE_INSTALL_PREFIX=/opt/eigen-3.4 \ - -DEIGEN_BUILD_BLAS=OFF -DEIGEN_BUILD_LAPACK=OFF -DEIGEN_BUILD_DOC=OFF -DBUILD_TESTING=OFF; \ - cmake --install eigen-build; \ - cd /; rm -rf /tmp/eigen /tmp/eigen-build +RUN /opt/jfjoch-common/install-eigen.sh # Make Qt, the static libdbus, and Eigen discoverable by CMake. The static libdbus prefix is # required here (not only at Qt build time): every Qt6::DBus consumer re-runs find_package(DBus1) @@ -221,3 +169,5 @@ WORKDIR /workspace # Default entrypoint: interactive shell CMD ["/bin/bash", "-l"] + +RUN rm -rf /opt/jfjoch-common diff --git a/docker/ubuntu2204/Dockerfile b/docker/ubuntu2204/Dockerfile index cf0fb8686..24044cd7d 100644 --- a/docker/ubuntu2204/Dockerfile +++ b/docker/ubuntu2204/Dockerfile @@ -80,16 +80,6 @@ RUN set -eux; \ libassimp-dev \ libglvnd-dev \ libfreetype6-dev; \ - wget -qO- https://apt.kitware.com/keys/kitware-archive-latest.asc \ - | gpg --dearmor \ - | tee /usr/share/keyrings/kitware-archive-keyring.gpg > /dev/null; \ - echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main" \ - | tee /etc/apt/sources.list.d/kitware.list > /dev/null; \ - apt-get update; \ - apt-get install -y --no-install-recommends \ - cmake=3.26.* \ - cmake-data=3.26.* \ - kitware-archive-keyring; \ apt-get -y install gcc-12 g++-12; \ apt-get clean; \ rm -rf /var/lib/apt/lists/* @@ -103,18 +93,19 @@ RUN git config --system http.version HTTP/1.1 # Use GCC/G++ 12 for builds ENV CC=/usr/bin/gcc-12 ENV CXX=/usr/bin/g++-12 -ENV PATH=/usr/bin:${PATH} # Build a static OpenSSL -RUN set -eux; \ - cd /tmp; \ - curl -LO https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz; \ - tar -xf openssl-${OPENSSL_VERSION}.tar.gz; \ - cd openssl-${OPENSSL_VERSION}; \ - ./Configure linux-x86_64 no-shared no-module no-tests --prefix=/opt/openssl-${OPENSSL_VERSION} --libdir=lib; \ - make -j"$(nproc)"; \ - make install_sw; \ - cd /; rm -rf /tmp/openssl-${OPENSSL_VERSION} /tmp/openssl-${OPENSSL_VERSION}.tar.gz +# Everything built from source below is identical in all four build images, so it lives in +# docker/common/ and is run from there -- one copy to change, not four. The build context is +# docker/ (see build_images.sh), which is what puts common/ in reach of this COPY. +ARG CMAKE_VERSION=3.31.8 +ARG CMAKE_SHA256=630615d8e98ac33eba7fbe472626dff5c899c85af3c024585ae109166a6909d0 +COPY common/ /opt/jfjoch-common/ +RUN /opt/jfjoch-common/install-cmake.sh +# Ahead of the distro path: the pinned CMake is the one every later step and every CI build uses. +ENV PATH=/opt/cmake-${CMAKE_VERSION}/bin:${PATH} + +RUN /opt/jfjoch-common/build-openssl.sh # Expose static OpenSSL to CMake/pkg-config ENV OPENSSL_ROOT_DIR=/opt/openssl-${OPENSSL_VERSION} @@ -139,68 +130,17 @@ RUN set -eux; \ # installs, which imports libdbus-1.a). Built -fPIC (--with-pic) so the archive links into Qt's PIE # tools (qdbusxml2cpp). expat is only a configure-time dep of the dbus daemon; the client libdbus-1 # links neither expat nor systemd. -RUN set -eux; \ - cd /tmp; \ - curl -LO https://dbus.freedesktop.org/releases/dbus/dbus-${DBUS_VERSION}.tar.xz; \ - tar -xf dbus-${DBUS_VERSION}.tar.xz; \ - cd dbus-${DBUS_VERSION}; \ - ./configure --prefix=/opt/dbus-${DBUS_VERSION}-static \ - --enable-static --disable-shared --with-pic \ - --disable-systemd --without-systemdsystemunitdir \ - --disable-selinux --disable-apparmor --disable-libaudit \ - --disable-tests --disable-asserts \ - --disable-doxygen-docs --disable-xml-docs --disable-ducktype-docs \ - CFLAGS="-fPIC"; \ - make -j"$(nproc)"; \ - make install; \ - cd /; rm -rf /tmp/dbus-${DBUS_VERSION} /tmp/dbus-${DBUS_VERSION}.tar.xz +RUN /opt/jfjoch-common/build-dbus.sh # Put the static libdbus pkgconfig ahead of the system one so Qt6::DBus resolves to the .a ENV PKG_CONFIG_PATH=/opt/dbus-${DBUS_VERSION}-static/lib/pkgconfig:${PKG_CONFIG_PATH} # Build and install static Qt with Core, Gui, Widgets, Charts, DBus ARG QT_PREFIX=/opt/qt-${QT_VERSION}-static -RUN set -eux; \ - cd /tmp; \ - curl -LO https://download.qt.io/official_releases/qt/6.9/${QT_VERSION}/single/qt-everywhere-src-${QT_VERSION}.tar.xz; \ - tar -xf qt-everywhere-src-${QT_VERSION}.tar.xz; \ - mkdir -p qt-everywhere-src-${QT_VERSION}/build && cd qt-everywhere-src-${QT_VERSION}/build; \ - cmake -G Ninja \ - -DQT_BUILD_SUBMODULES="qtbase;qtshadertools;qtdeclarative;qtcharts;qt3d" \ - -DBUILD_SHARED_LIBS=OFF \ - -DQT_BUILD_TESTS=OFF \ - -DQT_BUILD_EXAMPLES=OFF \ - -DQT_FEATURE_dbus=ON \ - -DQT_FEATURE_dbus_linked=ON \ - -DDBus1_DIR=/opt/dbus-${DBUS_VERSION}-static/lib/cmake/DBus1 \ - -DQT_FEATURE_xcb=ON \ - -DQT_FEATURE_xcb_xlib=OFF \ - -DQT_FEATURE_xkbcommon_x11=ON \ - -DQT_FEATURE_opengl=ON \ - -DQT_FEATURE_opengl_desktop=ON \ - -DQT_FEATURE_opengl_dynamic=OFF \ - -DQT_FEATURE_vulkan=OFF \ - -DQT_FEATURE_glib=OFF \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX=${QT_PREFIX} \ - -DCMAKE_C_COMPILER=${CC} \ - -DCMAKE_CXX_COMPILER=${CXX} \ - -DQT_FEATURE_openssl=ON \ - -DQT_FEATURE_openssl_linked=ON \ - -DOPENSSL_USE_STATIC_LIBS=TRUE \ - ..; \ - cmake --build . -j"$(nproc)"; \ - cmake --install .; \ - cd /; rm -rf /tmp/qt-everywhere-src-${QT_VERSION} /tmp/qt-everywhere-src-${QT_VERSION}.tar.xz +RUN /opt/jfjoch-common/build-qt.sh # Eigen 3.4 (header-only) -- external find_package(Eigen3 3.4) dependency, installed to /opt/eigen-3.4. -RUN set -eux; \ - cd /tmp; \ - git clone --depth 1 --branch ${EIGEN_VERSION} https://gitlab.com/libeigen/eigen.git; \ - cmake -G Ninja -S eigen -B eigen-build -DCMAKE_INSTALL_PREFIX=/opt/eigen-3.4 \ - -DEIGEN_BUILD_BLAS=OFF -DEIGEN_BUILD_LAPACK=OFF -DEIGEN_BUILD_DOC=OFF -DBUILD_TESTING=OFF; \ - cmake --install eigen-build; \ - cd /; rm -rf /tmp/eigen /tmp/eigen-build +RUN /opt/jfjoch-common/install-eigen.sh # Make Qt, the static libdbus, and Eigen discoverable by CMake. The static libdbus prefix is # required here (not only at Qt build time): every Qt6::DBus consumer re-runs find_package(DBus1) @@ -212,3 +152,5 @@ WORKDIR /workspace # Default entrypoint: interactive shell CMD ["/bin/bash", "-l"] + +RUN rm -rf /opt/jfjoch-common diff --git a/docker/ubuntu2404/Dockerfile b/docker/ubuntu2404/Dockerfile index 0f13a0e75..0b4f0ce00 100644 --- a/docker/ubuntu2404/Dockerfile +++ b/docker/ubuntu2404/Dockerfile @@ -39,7 +39,6 @@ RUN set -eux; \ tar \ xz-utils \ build-essential \ - cmake \ ninja-build \ python3 \ python3-venv \ @@ -105,15 +104,17 @@ ENV CC=/usr/bin/gcc ENV CXX=/usr/bin/g++ # Build a static OpenSSL -RUN set -eux; \ - cd /tmp; \ - curl -LO https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz; \ - tar -xf openssl-${OPENSSL_VERSION}.tar.gz; \ - cd openssl-${OPENSSL_VERSION}; \ - ./Configure linux-x86_64 no-shared no-module no-tests --prefix=/opt/openssl-${OPENSSL_VERSION} --libdir=lib; \ - make -j"$(nproc)"; \ - make install_sw; \ - cd /; rm -rf /tmp/openssl-${OPENSSL_VERSION} /tmp/openssl-${OPENSSL_VERSION}.tar.gz +# Everything built from source below is identical in all four build images, so it lives in +# docker/common/ and is run from there -- one copy to change, not four. The build context is +# docker/ (see build_images.sh), which is what puts common/ in reach of this COPY. +ARG CMAKE_VERSION=3.31.8 +ARG CMAKE_SHA256=630615d8e98ac33eba7fbe472626dff5c899c85af3c024585ae109166a6909d0 +COPY common/ /opt/jfjoch-common/ +RUN /opt/jfjoch-common/install-cmake.sh +# Ahead of the distro path: the pinned CMake is the one every later step and every CI build uses. +ENV PATH=/opt/cmake-${CMAKE_VERSION}/bin:${PATH} + +RUN /opt/jfjoch-common/build-openssl.sh # Expose static OpenSSL to CMake/pkg-config ENV OPENSSL_ROOT_DIR=/opt/openssl-${OPENSSL_VERSION} @@ -138,68 +139,17 @@ RUN set -eux; \ # installs, which imports libdbus-1.a). Built -fPIC (--with-pic) so the archive links into Qt's PIE # tools (qdbusxml2cpp). expat is only a configure-time dep of the dbus daemon; the client libdbus-1 # links neither expat nor systemd. -RUN set -eux; \ - cd /tmp; \ - curl -LO https://dbus.freedesktop.org/releases/dbus/dbus-${DBUS_VERSION}.tar.xz; \ - tar -xf dbus-${DBUS_VERSION}.tar.xz; \ - cd dbus-${DBUS_VERSION}; \ - ./configure --prefix=/opt/dbus-${DBUS_VERSION}-static \ - --enable-static --disable-shared --with-pic \ - --disable-systemd --without-systemdsystemunitdir \ - --disable-selinux --disable-apparmor --disable-libaudit \ - --disable-tests --disable-asserts \ - --disable-doxygen-docs --disable-xml-docs --disable-ducktype-docs \ - CFLAGS="-fPIC"; \ - make -j"$(nproc)"; \ - make install; \ - cd /; rm -rf /tmp/dbus-${DBUS_VERSION} /tmp/dbus-${DBUS_VERSION}.tar.xz +RUN /opt/jfjoch-common/build-dbus.sh # Put the static libdbus pkgconfig ahead of the system one so Qt6::DBus resolves to the .a ENV PKG_CONFIG_PATH=/opt/dbus-${DBUS_VERSION}-static/lib/pkgconfig:${PKG_CONFIG_PATH} # Build and install static Qt with Core, Gui, Widgets, Charts, DBus ARG QT_PREFIX=/opt/qt-${QT_VERSION}-static -RUN set -eux; \ - cd /tmp; \ - curl -LO https://download.qt.io/official_releases/qt/6.9/${QT_VERSION}/single/qt-everywhere-src-${QT_VERSION}.tar.xz; \ - tar -xf qt-everywhere-src-${QT_VERSION}.tar.xz; \ - mkdir -p qt-everywhere-src-${QT_VERSION}/build && cd qt-everywhere-src-${QT_VERSION}/build; \ - cmake -G Ninja \ - -DQT_BUILD_SUBMODULES="qtbase;qtshadertools;qtdeclarative;qtcharts;qt3d" \ - -DBUILD_SHARED_LIBS=OFF \ - -DQT_BUILD_TESTS=OFF \ - -DQT_BUILD_EXAMPLES=OFF \ - -DQT_FEATURE_dbus=ON \ - -DQT_FEATURE_dbus_linked=ON \ - -DDBus1_DIR=/opt/dbus-${DBUS_VERSION}-static/lib/cmake/DBus1 \ - -DQT_FEATURE_xcb=ON \ - -DQT_FEATURE_xcb_xlib=OFF \ - -DQT_FEATURE_xkbcommon_x11=ON \ - -DQT_FEATURE_opengl=ON \ - -DQT_FEATURE_opengl_desktop=ON \ - -DQT_FEATURE_opengl_dynamic=OFF \ - -DQT_FEATURE_vulkan=OFF \ - -DQT_FEATURE_glib=OFF \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX=${QT_PREFIX} \ - -DCMAKE_C_COMPILER=${CC} \ - -DCMAKE_CXX_COMPILER=${CXX} \ - -DQT_FEATURE_openssl=ON \ - -DQT_FEATURE_openssl_linked=ON \ - -DOPENSSL_USE_STATIC_LIBS=TRUE \ - ..; \ - cmake --build . -j"$(nproc)"; \ - cmake --install .; \ - cd /; rm -rf /tmp/qt-everywhere-src-${QT_VERSION} /tmp/qt-everywhere-src-${QT_VERSION}.tar.xz +RUN /opt/jfjoch-common/build-qt.sh # Eigen 3.4 (header-only) -- external find_package(Eigen3 3.4) dependency, installed to /opt/eigen-3.4. -RUN set -eux; \ - cd /tmp; \ - git clone --depth 1 --branch ${EIGEN_VERSION} https://gitlab.com/libeigen/eigen.git; \ - cmake -G Ninja -S eigen -B eigen-build -DCMAKE_INSTALL_PREFIX=/opt/eigen-3.4 \ - -DEIGEN_BUILD_BLAS=OFF -DEIGEN_BUILD_LAPACK=OFF -DEIGEN_BUILD_DOC=OFF -DBUILD_TESTING=OFF; \ - cmake --install eigen-build; \ - cd /; rm -rf /tmp/eigen /tmp/eigen-build +RUN /opt/jfjoch-common/install-eigen.sh # Make Qt, the static libdbus, and Eigen discoverable by CMake. The static libdbus prefix is # required here (not only at Qt build time): every Qt6::DBus consumer re-runs find_package(DBus1) @@ -253,3 +203,5 @@ WORKDIR /workspace # Default entrypoint: interactive shell CMD ["/bin/bash", "-l"] + +RUN rm -rf /opt/jfjoch-common