Files
leleka/deploy/Dockerfile.windows-build

31 lines
1.7 KiB
Docker

# Cross-compiles the Windows (x86_64-pc-windows-gnu) runtime binaries in a Linux container, so no Visual Studio is
# needed on the build machine. Build context: the repository root.
# docker build -f deploy/Dockerfile.windows-build -o type=local,dest=dist/windows .
# The binaries are written to dist/windows (ignored by Git). The mingw runtime is linked statically; OpenVINO is
# still loaded at run time from a separately obtained install.
FROM rust:1.99-bookworm AS build
RUN apt-get update \
&& apt-get install -y --no-install-recommends gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 binutils-mingw-w64-x86-64 cmake \
&& rm -rf /var/lib/apt/lists/* \
&& rustup target add x86_64-pc-windows-gnu
WORKDIR /src
COPY . .
# the repository pins its toolchain (rust-toolchain.toml); add the target to that one
RUN rustup target add x86_64-pc-windows-gnu
ENV CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc \
CC_x86_64_pc_windows_gnu=x86_64-w64-mingw32-gcc \
CXX_x86_64_pc_windows_gnu=x86_64-w64-mingw32-g++ \
AR_x86_64_pc_windows_gnu=x86_64-w64-mingw32-ar \
RUSTFLAGS="-C target-feature=+crt-static"
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/src/target \
cargo build --release --target x86_64-pc-windows-gnu \
-p leleka-control-plane -p leleka-cpu-worker -p leleka-igpu-worker -p leleka-npu-worker \
-p leleka-npu-service -p leleka-gpu-npu-worker \
&& mkdir /out \
&& for b in leleka-api leleka-cpu-worker leleka-igpu-worker leleka-npu-worker leleka-npu-service leleka-gpu-npu-worker; do \
cp target/x86_64-pc-windows-gnu/release/$b.exe /out/; done
FROM scratch AS export
COPY --from=build /out/ /