1# Build eval-cli for Linux.
2#
3# Usage (from the zed repo root):
4# docker build --platform linux/amd64 -f crates/eval_cli/Dockerfile -t eval-cli-builder .
5# docker cp "$(docker create eval-cli-builder)":/eval-cli ./target/eval-cli
6#
7# Or use the helper script:
8# crates/eval_cli/script/build-linux
9
10FROM rust:1.93 AS builder
11
12WORKDIR /app
13
14 # Pre-install the toolchain specified in rust-toolchain.toml so it is cached.
15RUN rustup toolchain install 1.93 --profile minimal \
16 --component rustfmt --component clippy --component rust-analyzer --component rust-src \
17 --target wasm32-wasip2 --target wasm32-unknown-unknown --target x86_64-unknown-linux-musl --target x86_64-unknown-linux-gnu
18
19# Install build tools. cmake + build-essential are needed for vendored C
20# libraries (libgit2-sys, zstd-sys, libsqlite3-sys). No audio/GUI -dev
21# packages required — eval-cli runs headless with those features disabled.
22#
23# cargo-zigbuild cross-compiles against a specific glibc version (2.31 =
24# Debian Bullseye / Ubuntu Focal) so the resulting binary is portable to
25# any Linux distro with glibc >= 2.31.
26RUN apt-get update && apt-get install -y --no-install-recommends \
27 cmake \
28 build-essential \
29 curl \
30 xz-utils \
31 && rm -rf /var/lib/apt/lists/*
32
33RUN mkdir -p /opt/zig \
34 && curl -fsSL https://ziglang.org/download/0.15.2/zig-x86_64-linux-0.15.2.tar.xz \
35 | tar -xJ -C /opt/zig --strip-components=1 \
36 && ln -s /opt/zig/zig /usr/local/bin/zig
37
38RUN cargo install --locked cargo-zigbuild
39
40COPY . .
41
42RUN --mount=type=cache,target=/usr/local/cargo/registry \
43 --mount=type=cache,target=/usr/local/cargo/git \
44 --mount=type=cache,target=/app/target \
45 cargo zigbuild --release --package eval_cli \
46 --target x86_64-unknown-linux-gnu.2.31 && \
47 cp /app/target/x86_64-unknown-linux-gnu/release/eval-cli /eval-cli && \
48 strip /eval-cli
49
50FROM scratch
51COPY --from=builder /eval-cli /eval-cli