🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
build(docker): embed Rust dependency lists and simplify Rust tool installs (#19033)
Tobias Wochinger7393a37d9af0
diff --git a/ai-gateway/Dockerfile b/ai-gateway/Dockerfileindex c0caaa9f04..b904cbe648 100644--- a/ai-gateway/Dockerfile+++ b/ai-gateway/Dockerfile@@ -1,11 +1,10 @@-# FIPS 140-3 base: UBI 9 builder and ubi9-micro runtime-# The gateway performs no TLS today (plain HTTP; the dependency graph contains-# no openssl or rustls crates), so FIPS readiness here means the whole image-# lifecycle stays on the RHEL platform: the binary is compiled and linked-# against UBI9 glibc, and the runtime carries the CMVP-validated OpenSSL FIPS-# provider, so outbound TLS added later links the system libcrypto.so.3 and-# inherits the validated module, the same pattern the RPM Node uses in-# web/worker. The crypto policy stays at the default until the gateway does TLS.+# UBI 9 builder and ubi9-micro runtime, the same platform as web/worker.+# The gateway is not FIPS 140-3 validated. It serves plain HTTP, but its+# outbound HTTPS (provider APIs, OTLP export) uses rustls with the aws-lc-rs+# backend, statically linked in its non-FIPS build. The binary links no system+# libcrypto, so the OpenSSL FIPS provider in the runtime image does not cover+# it. Validated TLS would need aws-lc-rs's `fips` feature or an OpenSSL-backed+# client.# The defaults are Red Hat's public UBI9 images, so the build needs no# credentials. Iron Bank serves the same content from an authenticated registry# with DoD provenance and scan attestations. Release builds opt in by overriding@@ -53,20 +52,14 @@ RUN set -eux; \rm -rf /tmp/rust.tar.gz /tmp/rust-1.98.0-${triple}# cargo-about renders the third-party license notices shipped in the runtime-# image. Pinned, checksum-verified static release binary (sha256 from the-# release's `.tar.gz.sha256` assets), so the builder does not compile it.-RUN set -eux; \- case "${TARGETARCH:-amd64}" in \- amd64) about_arch=x86_64; about_sha256=9099a59e820c38a68b9d65f300662a567d56562f9a10f6aa4c7e86c17c2566af ;; \- arm64) about_arch=aarch64; about_sha256=af5169282fb6f84e13471493f405437e43ac517744c9ae12fbe2cdf0a6f0e5a8 ;; \- *) echo "unsupported TARGETARCH: ${TARGETARCH}" >&2; exit 1 ;; \- esac; \- about_dir="cargo-about-0.9.2-${about_arch}-unknown-linux-musl"; \- curl -fsSL -o /tmp/cargo-about.tar.gz "https://github.com/EmbarkStudios/cargo-about/releases/download/0.9.2/${about_dir}.tar.gz"; \- echo "${about_sha256} /tmp/cargo-about.tar.gz" | sha256sum -c -; \- tar -xzf /tmp/cargo-about.tar.gz -C /tmp; \- install -m 0755 "/tmp/${about_dir}/cargo-about" /usr/local/bin/cargo-about; \- rm -rf /tmp/cargo-about.tar.gz "/tmp/${about_dir}"+# image. cargo-auditable embeds the resolved dependency list in the binary so+# image scanners (Trivy, Grype, Docker Scout) can match its Rust crates against+# advisories; a stripped binary otherwise shows them nothing. Both build from+# crates.io at pinned versions with their own lockfiles; keep the versions in+# sync with worker/Dockerfile.+RUN cargo install --locked --root /usr/local --features cli [email protected] && \+ cargo install --locked --root /usr/local [email protected] && \+ rm -rf "${CARGO_HOME:-$HOME/.cargo}/registry"FROM --platform=${TARGETPLATFORM:-linux/amd64} toolchain AS deps@@ -92,7 +85,7 @@ RUN cargo build --release --frozen && \COPY src ./src-RUN cargo build --release --frozen+RUN cargo auditable build --release --frozen# Runs in parallel with the compile. `--frozen` reads licenses only from the# fetched crate sources, and `generate` fails on any dependency whose license@@ -112,11 +105,10 @@ RUN cargo about generate --frozen --fail about.hbs -o THIRD_PARTY_LICENSES.txtFROM --platform=${TARGETPLATFORM:-linux/amd64} ${BASE_IMAGE} AS rpm-installer# glibc and libgcc are the binary's dynamic dependencies (libgcc_s for panics).-# openssl-libs ships the FIPS provider module (/usr/lib64/ossl-modules/fips.so),-# unlinked by today's binary but required the moment an OpenSSL-dependent-# binary lands, so the validated module is already present. crypto-policies-# provides the system policy OpenSSL reads; ca-certificates is the trust store-# for future outbound TLS. wget serves the ECS container health command+# openssl-libs ships the OpenSSL FIPS provider module and crypto-policies the+# system policy it reads; the gateway binary links neither today, they are+# there for an OpenSSL-backed client. ca-certificates is the trust store rustls+# reads for outbound TLS. wget serves the ECS container health command# (`sh -c 'wget -qO /dev/null http://localhost:8080/health'`, exercised by# scripts/smoke-image.sh); ubi9-micro already provides the shell.RUN dnf -y --installroot /mnt/rootfs --releasever 9 --setopt=install_weak_deps=0 \diff --git a/worker/Dockerfile b/worker/Dockerfileindex e2db9f0019..00ba444739 100644--- a/worker/Dockerfile+++ b/worker/Dockerfile@@ -136,21 +136,17 @@ RUN set -eux; \rm -rf /tmp/rust.tar.gz /tmp/rust-1.98.0-${triple}# cargo-about renders the third-party license notices for the native addon's-# Rust dependencies. Pinned, checksum-verified static release binary (sha256-# from the release's `.tar.gz.sha256` assets); keep the version in sync with-# ai-gateway/Dockerfile.-RUN set -eux; \- case "${TARGETARCH:-amd64}" in \- amd64) about_arch=x86_64; about_sha256=9099a59e820c38a68b9d65f300662a567d56562f9a10f6aa4c7e86c17c2566af ;; \- arm64) about_arch=aarch64; about_sha256=af5169282fb6f84e13471493f405437e43ac517744c9ae12fbe2cdf0a6f0e5a8 ;; \- *) echo "unsupported TARGETARCH: ${TARGETARCH}" >&2; exit 1 ;; \- esac; \- about_dir="cargo-about-0.9.2-${about_arch}-unknown-linux-musl"; \- curl -fsSL -o /tmp/cargo-about.tar.gz "https://github.com/EmbarkStudios/cargo-about/releases/download/0.9.2/${about_dir}.tar.gz"; \- echo "${about_sha256} /tmp/cargo-about.tar.gz" | sha256sum -c -; \- tar -xzf /tmp/cargo-about.tar.gz -C /tmp; \- install -m 0755 "/tmp/${about_dir}/cargo-about" /usr/local/bin/cargo-about; \- rm -rf /tmp/cargo-about.tar.gz "/tmp/${about_dir}"+# Rust dependencies. cargo-auditable embeds the addon's resolved dependency+# list in the .node binary so image scanners (Trivy, Grype, Docker Scout) can+# match its Rust crates against advisories. Both build from crates.io at pinned+# versions with their own lockfiles; keep the versions in sync with+# ai-gateway/Dockerfile. `napi build` spawns $CARGO instead of cargo when it is+# set, so the build step points it at a wrapper that runs `cargo auditable`.+RUN cargo install --locked --root /usr/local --features cli [email protected] && \+ cargo install --locked --root /usr/local [email protected] && \+ rm -rf "${CARGO_HOME:-$HOME/.cargo}/registry" && \+ printf '#!/bin/sh\nexec /usr/local/bin/cargo auditable "$@"\n' > /usr/local/bin/cargo-auditable-shim && \+ chmod 0755 /usr/local/bin/cargo-auditable-shimFROM --platform=${TARGETPLATFORM:-linux/amd64} toolchain AS builder@@ -180,7 +176,7 @@ ARG NEXT_PUBLIC_POSTHOG_HOST# Copy source code of isolated subworkspaceCOPY --from=pruner /app/out/full/ .-RUN turbo run build --filter=worker...+RUN CARGO=/usr/local/bin/cargo-auditable-shim turbo run build --filter=worker...# Runs after the build so `cargo fetch` adds the sources the build skipped (dev# and other-target dependencies) that cargo metadata still reads; `generate`