From 3555fc83d227052eda16bfbb6f81aa4c7aeede97 Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Tue, 28 Nov 2023 21:53:33 +0100 Subject: [PATCH] ci: Rework MSVC image building This moves process of downloading and setting up the Windows libraries to a separate build step, freeing up the layers of the final image. --- .ci/image/Dockerfile.linux | 6 ++--- .ci/image/Dockerfile.msvc | 51 ++++++++++++++++++++++++++------------ Justfile | 6 ++--- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/.ci/image/Dockerfile.linux b/.ci/image/Dockerfile.linux index df10059..5cbaf5d 100644 --- a/.ci/image/Dockerfile.linux +++ b/.ci/image/Dockerfile.linux @@ -8,9 +8,9 @@ RUN set -eux; \ git \ gpg \ jq \ - libatk1.0-dev \ + libatk1.0-dev \ libclang-13-dev \ - libglib2.0-dev \ + libglib2.0-dev \ libgtk-3-dev \ libpango1.0-dev \ libssl-dev \ @@ -22,4 +22,4 @@ RUN set -eux; \ WORKDIR /src/dtmt -COPY *.so *.a /src/ +COPY lib/oodle/*.so lib/oodle/*.a /src/ diff --git a/.ci/image/Dockerfile.msvc b/.ci/image/Dockerfile.msvc index a9eab62..864dc73 100644 --- a/.ci/image/Dockerfile.msvc +++ b/.ci/image/Dockerfile.msvc @@ -1,13 +1,40 @@ # https://jake-shadle.github.io/xwin/ -FROM dtmt-ci-base-linux +FROM debian:bullseye-slim as xwin + +ARG XWIN_VERSION=0.5.0 +ARG XWIN_PREFIX="xwin-$XWIN_VERSION-x86_64-unknown-linux-musl" +ADD https://github.com/Jake-Shadle/xwin/releases/download/$XWIN_VERSION/$XWIN_PREFIX.tar.gz /root/$XWIN_PREFIX.tar.gz + +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y \ + tar \ + ; \ + # Install xwin to cargo/bin via github release. Note you could also just use `cargo install xwin`. + tar -xzv -f /root/$XWIN_PREFIX.tar.gz -C /usr/bin --strip-components=1 $XWIN_PREFIX/xwin; \ + apt-get remove -y --auto-remove; \ + rm -rf \ + /var/lib/apt/lists/* \ + /root/$XWIN_PREFIX.tar.gz; + +RUN set -eux; \ + # Splat the CRT and SDK files to /xwin/crt and /xwin/sdk respectively + xwin \ + --log-level debug \ + --cache-dir /root/.xwin-cache \ + --manifest-version 16 \ + --accept-license \ + splat \ + --output /xwin; \ + rm -rf \ + /root/.xwin-cache; + +FROM dtmt-ci-base-linux as final ENV KEYRINGS /usr/local/share/keyrings -ARG XWIN_VERSION=0.2.11 -ARG XWIN_PREFIX="xwin-$XWIN_VERSION-x86_64-unknown-linux-musl" ADD https://apt.llvm.org/llvm-snapshot.gpg.key /root/llvm-snapshot.gpg.key ADD https://dl.winehq.org/wine-builds/winehq.key /root/winehq.key -ADD https://github.com/Jake-Shadle/xwin/releases/download/$XWIN_VERSION/$XWIN_PREFIX.tar.gz /root/$XWIN_PREFIX.tar.gz RUN set -eux; \ mkdir -p $KEYRINGS; \ @@ -26,7 +53,7 @@ RUN set -eux; \ llvm-13 \ lld-13 \ winehq-staging \ - tar; \ + ; \ # ensure that clang/clang++ are callable directly ln -s clang-13 /usr/bin/clang && ln -s clang /usr/bin/clang++ && ln -s lld-13 /usr/bin/ld.lld; \ # We also need to setup symlinks ourselves for the MSVC shims because they aren't in the debian packages @@ -44,19 +71,15 @@ RUN set -eux; \ update-alternatives --install /usr/bin/ld ld /usr/bin/ld.lld 100; \ rustup target add x86_64-pc-windows-msvc; \ rustup component add rust-src; \ - # Install xwin to cargo/bin via github release. Note you could also just use `cargo install xwin`. - tar -xzv -f /root/$XWIN_PREFIX.tar.gz -C /usr/local/cargo/bin --strip-components=1 $XWIN_PREFIX/xwin; \ - # Splat the CRT and SDK files to /xwin/crt and /xwin/sdk respectively - xwin --accept-license splat --output /xwin; \ # Remove unneeded files to reduce image size apt-get remove -y --auto-remove; \ rm -rf \ - .xwin-cache \ - /usr/local/cargo/bin/xwin \ - /root/$XWIN_PREFIX.tar.gz \ /var/lib/apt/lists/* \ /root/*.key; +COPY lib/oodle/*.lib /src +COPY --from=xwin /xwin /xwin + # Note that we're using the full target triple for each variable instead of the # simple CC/CXX/AR shorthands to avoid issues when compiling any C/C++ code for # build dependencies that need to compile and execute in the host environment @@ -83,7 +106,3 @@ ENV CFLAGS_x86_64_pc_windows_msvc="$CL_FLAGS" \ # Run wineboot just to setup the default WINEPREFIX so we don't do it every # container run RUN wine wineboot --init - -WORKDIR /src/dtmt - -COPY *.lib /src diff --git a/Justfile b/Justfile index 12fde29..967619b 100644 --- a/Justfile +++ b/Justfile @@ -18,13 +18,13 @@ build-image-linux: ci-image: ci-image-msvc ci-image-linux -ci-image-msvc: ci-image-linux - docker build -t dtmt-ci-base-msvc -f .ci/image/Dockerfile.msvc .ci/image +ci-image-msvc: + docker build -t dtmt-ci-base-msvc -f .ci/image/Dockerfile.msvc . docker tag dtmt-ci-base-msvc registry.sclu1034.dev/dtmt-ci-base-msvc docker push registry.sclu1034.dev/dtmt-ci-base-msvc ci-image-linux: - docker build -t dtmt-ci-base-linux -f .ci/image/Dockerfile.linux .ci/image + docker build -t dtmt-ci-base-linux -f .ci/image/Dockerfile.linux . docker tag dtmt-ci-base-linux registry.sclu1034.dev/dtmt-ci-base-linux docker push registry.sclu1034.dev/dtmt-ci-base-linux