Files
DarkRoom/docker/macos/Dockerfile
T
dtourolle ff4b30fbaa Link the inference engine for macOS in a zig container
`docker/macos` builds for aarch64-apple-darwin from Linux with
cargo-zigbuild. Zig carries libSystem and the C headers, so tract's SIMD
kernels compile and the engine's test binaries and examples link as Mach-O
arm64 — the check `cargo check --target` could not do, because tract's
build script needs a macOS C compiler. Crates that link an Apple framework
(dr-plat's keyring, and so the app) still need the Xcode SDK and fail at
the link; macos.md says so.
2026-10-03 16:50:37 -04:00

49 lines
2.2 KiB
Docker

# DarkRoom — macOS link check
#
# Compiles and links for macOS from Linux, with zig as the linker
# (cargo-zigbuild). Zig carries macOS's libSystem stubs and C headers, so the
# crates that need only libSystem — the inference engine, dr-plat — build,
# link and produce Mach-O test binaries here. Nothing runs: there is no macOS
# to run them on (docs/dev/macos.md §2). The desktop app needs Apple's
# framework headers (AppKit, Metal, Security), which only the Xcode SDK
# carries, so it does not link here.
#
# Build: docker build -t darkroom-macos:latest docker/macos
# Use: ./docker/macos/build.sh cargo zigbuild --target aarch64-apple-darwin -p dr-inference-engine --all-targets
FROM docker.io/library/debian:trixie-slim
# Pinned, like the Windows and Android images. Rust matches rust-toolchain.toml.
ARG RUST_VERSION=1.92.0
ARG ZIG_VERSION=0.15.2
ARG ZIG_SHA256=02aa270f183da276e5b5920b1dac44a63f1a49e55050ebde3aecc9eb82f93239
ARG CARGO_ZIGBUILD_VERSION=0.23.4
ENV DEBIAN_FRONTEND=noninteractive \
CARGO_HOME=/opt/cargo \
RUSTUP_HOME=/opt/rustup \
PATH=/opt/zig:/opt/cargo/bin:$PATH
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl git xz-utils \
# A host C compiler: build scripts and proc-macros are Linux binaries.
gcc libc6-dev \
# `file` says Mach-O; the smoke check in build.sh reads it.
file \
&& rm -rf /var/lib/apt/lists/*
RUN curl -fsSL "https://ziglang.org/download/${ZIG_VERSION}/zig-x86_64-linux-${ZIG_VERSION}.tar.xz" -o /tmp/zig.tar.xz \
&& echo "${ZIG_SHA256} /tmp/zig.tar.xz" | sha256sum -c - \
&& mkdir /opt/zig && tar xJf /tmp/zig.tar.xz -C /opt/zig --strip-components=1 \
&& rm /tmp/zig.tar.xz && zig version
# The components rust-toolchain.toml lists, baked in so rustup does not fetch
# them inside every run.
RUN curl -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal \
--default-toolchain "${RUST_VERSION}" \
--component rustfmt,clippy,rust-analyzer \
--target aarch64-apple-darwin,x86_64-apple-darwin \
&& cargo install --locked "cargo-zigbuild@${CARGO_ZIGBUILD_VERSION}" \
&& rm -rf /opt/cargo/registry \
&& chmod -R a+rwX /opt/cargo /opt/rustup