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.
This commit is contained in:
Lucas Schwiderski 2023-11-28 21:53:33 +01:00
parent 227dff03ef
commit 3555fc83d2
Signed by: lucas
GPG key ID: AA12679AAA6DF4D8
3 changed files with 41 additions and 22 deletions

View file

@ -22,4 +22,4 @@ RUN set -eux; \
WORKDIR /src/dtmt
COPY *.so *.a /src/
COPY lib/oodle/*.so lib/oodle/*.a /src/

View file

@ -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

View file

@ -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