# Multi-stage build for Linux amd64 and arm64. The build runs natively for the # selected Docker platform; production selects linux/amd64 explicitly. FROM debian:bookworm-slim AS builder ARG ZIG_VERSION=0.17.0 RUN apt-get update && apt-get install -y --no-install-recommends curl xz-utils ca-certificates && rm -rf /var/lib/apt/lists/* RUN set -eux; \ case "$(dpkg --print-architecture)" in \ amd64) zig_arch=x86_64; zig_sha256=1cbe9df9f27e6b78d14ccbca43b6703a404ef79ef1c463de901d7f088d4e2026 ;; \ arm64) zig_arch=aarch64; zig_sha256=9e8d11661d4ae3bd57702a3832781e23ad151dde5798e16a5ccd503f65234ff8 ;; \ *) echo "unsupported architecture: $(dpkg --print-architecture)" >&2; exit 1 ;; \ esac; \ curl -fSL "https://ziglang.org/download/${ZIG_VERSION}/zig-${zig_arch}-linux-${ZIG_VERSION}.tar.xz" -o /tmp/zig.tar.xz; \ echo "${zig_sha256} /tmp/zig.tar.xz" | sha256sum --check -; \ tar xJf /tmp/zig.tar.xz -C /opt; \ rm /tmp/zig.tar.xz; \ mv "/opt/zig-${zig_arch}-linux-${ZIG_VERSION}" /opt/zig ENV PATH=/opt/zig:$PATH WORKDIR /build # fetch dependencies first (cacheable — only changes when build.zig.zon changes) COPY build.zig build.zig.zon ./ RUN for delay in 0 2 5; do \ sleep "$delay"; \ zig build --fetch=all && exit 0; \ done; \ exit 1 # then copy source and build COPY src/ src/ # Io.Threaded is the production backend; the old Io.Uring stdlib patch is not # needed. Keep glibc for its allocator behavior under the thread-per-PDS model. RUN set -eux; \ case "$(dpkg --print-architecture)" in \ amd64) target=x86_64-linux-gnu ;; \ arm64) target=aarch64-linux-gnu ;; \ *) echo "unsupported architecture: $(dpkg --print-architecture)" >&2; exit 1 ;; \ esac; \ zig build -Doptimize=ReleaseSafe -Dcpu=baseline "-Dtarget=${target}" FROM debian:bookworm-slim RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/* COPY --from=builder /build/zig-out/bin/zlay /usr/local/bin/zlay RUN mkdir -p /data/events /data/collection-index ENV RELAY_DATA_DIR=/data/events EXPOSE 3000 3001 ENTRYPOINT ["/usr/local/bin/zlay"]