Files
asteria-qt/docker/Dockerfile.build
T
2026-11-13 14:07:56 +01:00

189 lines
7.7 KiB
INI

# Multi-stage CI runner images for asteria-qt (all sharing the `base` layer).
# Targets:
# - linux-x86_64 : Native Linux x86_64 build, CTest, AppImage packaging, and wiki jobs
# - linux-arm64 : Cross-compiled Linux ARM64 build and AppImage packaging
# - windows-x86_64 : Cross-compiled Windows x86_64 build and portable zip packaging
# - windows-arm64 : Cross-compiled Windows ARM64 build and portable zip packaging
FROM ubuntu:24.04 AS base
ARG QT_VERSION=6.12.0
ARG QT_INSTALL_DIR=/opt/qt
ENV DEBIAN_FRONTEND=noninteractive
ENV QT_VERSION=${QT_VERSION}
ENV QT_INSTALL_DIR=${QT_INSTALL_DIR}
ENV QT_LINUX_DIR=${QT_INSTALL_DIR}/${QT_VERSION}/gcc_64
# ── Core CLI tools, Qt host runtime libs, and host Qt 6 (QT_HOST_PATH) ─────────
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends \
ca-certificates \
cmake \
curl \
file \
git \
jq \
libdbus-1-3 \
libegl1 \
libfontconfig1 \
libfreetype6 \
libgl1 \
libglib2.0-0t64 \
libxkbcommon0 \
ninja-build \
pkg-config \
python3 \
python3-venv \
wget \
xz-utils \
zip \
zstd \
&& rm -rf /var/lib/apt/lists/* \
&& python3 -m venv /tmp/aqt-venv \
&& /tmp/aqt-venv/bin/pip install --quiet aqtinstall \
&& /tmp/aqt-venv/bin/aqt install-qt linux desktop "${QT_VERSION}" linux_gcc_64 \
-m qtimageformats --outputdir "${QT_INSTALL_DIR}" \
&& rm -rf /tmp/aqt-venv \
&& rm -rf \
"${QT_LINUX_DIR}/doc" \
"${QT_LINUX_DIR}/examples"
# ── gitlab-runner (shell executor) ─────────────────────────────────────────────
RUN wget -q https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64 \
-O /usr/local/bin/gitlab-runner && \
chmod +x /usr/local/bin/gitlab-runner && \
mkdir -p /etc/gitlab-runner /builds && \
chmod 777 /builds
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD []
# ==============================================================================
# Shared Linux packaging layer (patchelf + binutils/readelf + appimagetool)
# ==============================================================================
FROM base AS linux-base
# Note: Zeroing AppImage magic bytes 8-10 allows extraction under both native Linux and Rosetta 2
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends binutils patchelf && \
rm -rf /var/lib/apt/lists/* && \
mkdir -p /opt/appimage && \
wget -q https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage \
-O /tmp/appimagetool && \
chmod +x /tmp/appimagetool && \
printf '\000\000\000' | dd of=/tmp/appimagetool bs=1 seek=8 count=3 conv=notrunc && \
cd /tmp && /tmp/appimagetool --appimage-extract && \
mv squashfs-root /opt/appimagetool && \
ln -sf /opt/appimagetool/AppRun /usr/local/bin/appimagetool && \
rm /tmp/appimagetool
# ==============================================================================
# Target 1: Linux x86_64 (native build, CTest, AppImage, wiki)
# ==============================================================================
FROM linux-base AS linux-x86_64
COPY scripts/install-deps-ubuntu.sh /tmp/install-deps-ubuntu.sh
RUN chmod +x /tmp/install-deps-ubuntu.sh && \
QT_VERSION=${QT_VERSION} QT_INSTALL_DIR=${QT_INSTALL_DIR} \
/tmp/install-deps-ubuntu.sh --skip-qt && \
rm -rf /tmp/install-deps-ubuntu.sh /var/lib/apt/lists/* && \
wget -q https://github.com/AppImage/type2-runtime/releases/download/continuous/runtime-x86_64 \
-O /opt/appimage/runtime-x86_64 && \
chmod +x /opt/appimage/runtime-x86_64 && \
g++ --version
# ==============================================================================
# Target 2: Linux ARM64 (aarch64 cross-compile + AppImage)
# ==============================================================================
FROM linux-base AS linux-arm64
ENV QT_LINUX_ARM64_DIR=${QT_INSTALL_DIR}/${QT_VERSION}/gcc_arm64
COPY scripts/install-deps-ubuntu.sh /tmp/install-deps-ubuntu.sh
RUN chmod +x /tmp/install-deps-ubuntu.sh && \
QT_VERSION=${QT_VERSION} QT_INSTALL_DIR=${QT_INSTALL_DIR} \
/tmp/install-deps-ubuntu.sh --only-arm64 && \
rm -rf /tmp/install-deps-ubuntu.sh /var/lib/apt/lists/* \
"${QT_LINUX_ARM64_DIR}/doc" \
"${QT_LINUX_ARM64_DIR}/examples" && \
wget -q https://github.com/AppImage/type2-runtime/releases/download/continuous/runtime-aarch64 \
-O /opt/appimage/runtime-aarch64 && \
chmod +x /opt/appimage/runtime-aarch64
COPY scripts/linux-arm64-toolchain.cmake /opt/linux-arm64-toolchain.cmake
# ==============================================================================
# Shared Windows cross-compilation base (llvm-mingw pruned to 64-bit targets)
# ==============================================================================
FROM base AS windows-base
ARG LLVM_MINGW_VERSION=20240917
RUN wget -q https://github.com/mstorsjo/llvm-mingw/releases/download/${LLVM_MINGW_VERSION}/llvm-mingw-${LLVM_MINGW_VERSION}-ucrt-ubuntu-20.04-x86_64.tar.xz \
-O /tmp/llvm-mingw.tar.xz && \
tar -xf /tmp/llvm-mingw.tar.xz -C /opt && \
mv /opt/llvm-mingw-${LLVM_MINGW_VERSION}-ucrt-ubuntu-20.04-x86_64 /opt/llvm-mingw && \
rm -rf /tmp/llvm-mingw.tar.xz \
/opt/llvm-mingw/i686-w64-mingw32 \
/opt/llvm-mingw/armv7-w64-mingw32 \
/opt/llvm-mingw/bin/i686-* \
/opt/llvm-mingw/bin/armv7-*
ENV PATH="/opt/llvm-mingw/bin:${PATH}"
# ==============================================================================
# Target 3: Windows x86_64 (LLVM-MinGW + MSYS2 clang64 Qt 6)
# ==============================================================================
FROM windows-base AS windows-x86_64
ENV QT_WINDOWS_DIR=${QT_INSTALL_DIR}/${QT_VERSION}/mingw_64
ENV MINGW_SYSROOT=${QT_WINDOWS_DIR}
COPY scripts/download-mingw-arm64-qt.py /tmp/download-mingw-arm64-qt.py
RUN chmod +x /tmp/download-mingw-arm64-qt.py && \
python3 /tmp/download-mingw-arm64-qt.py --arch x86_64 --dest "${QT_WINDOWS_DIR}" && \
rm -rf \
"${QT_WINDOWS_DIR}/share/doc" \
"${QT_WINDOWS_DIR}/share/man" \
"${QT_WINDOWS_DIR}/share/info" \
"${QT_WINDOWS_DIR}/share/qt6/doc" \
"${QT_WINDOWS_DIR}/share/qt6/examples" && \
ln -sfn "${QT_WINDOWS_DIR}" /opt/mingw-sysroot && \
rm /tmp/download-mingw-arm64-qt.py && \
x86_64-w64-mingw32-g++ --version
COPY scripts/mingw-w64-toolchain.cmake /opt/mingw-w64-toolchain.cmake
# ==============================================================================
# Target 4: Windows ARM64 (LLVM-MinGW + MSYS2 clangarm64 Qt 6)
# ==============================================================================
FROM windows-base AS windows-arm64
ENV QT_WINDOWS_ARM64_DIR=${QT_INSTALL_DIR}/${QT_VERSION}/mingw_arm64
ENV MINGW_ARM64_SYSROOT=${QT_WINDOWS_ARM64_DIR}
COPY scripts/download-mingw-arm64-qt.py /tmp/download-mingw-arm64-qt.py
RUN chmod +x /tmp/download-mingw-arm64-qt.py && \
python3 /tmp/download-mingw-arm64-qt.py --arch arm64 --dest "${QT_WINDOWS_ARM64_DIR}" && \
rm -rf \
"${QT_WINDOWS_ARM64_DIR}/share/doc" \
"${QT_WINDOWS_ARM64_DIR}/share/man" \
"${QT_WINDOWS_ARM64_DIR}/share/info" \
"${QT_WINDOWS_ARM64_DIR}/share/qt6/doc" \
"${QT_WINDOWS_ARM64_DIR}/share/qt6/examples" && \
ln -sfn "${QT_WINDOWS_ARM64_DIR}" /opt/mingw-arm64-sysroot && \
rm /tmp/download-mingw-arm64-qt.py && \
aarch64-w64-mingw32-g++ --version
COPY scripts/mingw-w64-arm64-toolchain.cmake /opt/mingw-w64-arm64-toolchain.cmake