From 75197b337813127ff125f7eed920310f10989e88 Mon Sep 17 00:00:00 2001 From: Peter Pan Date: Fri, 14 Aug 2026 15:39:38 +0800 Subject: [PATCH 1/3] feat(server): add Dockerfile for switchyard-server container image Signed-off-by: Peter Pan --- .dockerignore | 1 + Dockerfile | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore index 0941d4626..21ce6789e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,6 +3,7 @@ .pytest_cache .ruff_cache .venv +target .worktrees benchmark/datasets benchmark/tb_runs diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..98f3a6d47 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# Build the standalone switchyard-server binary against the workspace lockfile. +FROM rust:1.96-bookworm AS builder +WORKDIR /app +COPY Cargo.toml Cargo.lock rust-toolchain.toml ./ +COPY crates/ crates/ +RUN cargo build --release --locked --package switchyard-server + +# Runtime image: binary only, runs unprivileged. Mount a TOML deployment at +# /etc/switchyard/config.toml and pass provider API keys as env vars. +FROM debian:bookworm-slim +RUN apt-get update \ + && apt-get install --yes --no-install-recommends ca-certificates \ + && rm -rf /var/lib/apt/lists/* \ + && useradd --system --uid 10001 switchyard +COPY --from=builder /app/target/release/switchyard-server /usr/local/bin/switchyard-server +USER switchyard +EXPOSE 4000 +ENTRYPOINT ["switchyard-server"] +CMD ["--config", "/etc/switchyard/config.toml"] From fd3b7c1f6911a84bf18781f8e12263deb31d5a3e Mon Sep 17 00:00:00 2001 From: Peter Pan Date: Fri, 14 Aug 2026 15:54:03 +0800 Subject: [PATCH 2/3] fix(server): apply workspace cargo rustflags and pin builder tag in Dockerfile Signed-off-by: Peter Pan --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 98f3a6d47..9523c3a9b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,10 @@ # SPDX-License-Identifier: Apache-2.0 # Build the standalone switchyard-server binary against the workspace lockfile. -FROM rust:1.96-bookworm AS builder +FROM rust:1.96.1-bookworm AS builder WORKDIR /app COPY Cargo.toml Cargo.lock rust-toolchain.toml ./ +COPY .cargo/ .cargo/ COPY crates/ crates/ RUN cargo build --release --locked --package switchyard-server From 31463243daaba49f5b3b99029492bb8623a7e72c Mon Sep 17 00:00:00 2001 From: Peter Pan Date: Sat, 15 Aug 2026 19:38:30 +0800 Subject: [PATCH 3/3] refactor(server): consolidate benchmark Dockerfile into root Dockerfile Signed-off-by: Peter Pan --- Dockerfile | 36 +++++++++++++-------- benchmark/README.md | 2 +- benchmark/run-baseline.sh | 2 +- benchmark/switchyard-rust-server.Dockerfile | 28 ---------------- 4 files changed, 24 insertions(+), 44 deletions(-) delete mode 100644 benchmark/switchyard-rust-server.Dockerfile diff --git a/Dockerfile b/Dockerfile index 9523c3a9b..eb6815eea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,31 @@ # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -# Build the standalone switchyard-server binary against the workspace lockfile. -FROM rust:1.96.1-bookworm AS builder -WORKDIR /app +# Keep RUST_VERSION in sync with rust-toolchain.toml. +ARG RUST_VERSION=1.96.1 +FROM rust:${RUST_VERSION}-bookworm AS builder + +WORKDIR /opt/switchyard COPY Cargo.toml Cargo.lock rust-toolchain.toml ./ -COPY .cargo/ .cargo/ -COPY crates/ crates/ -RUN cargo build --release --locked --package switchyard-server +# .cargo/config.toml carries the workspace rustflags (target-cpu, force-frame-pointers). +COPY .cargo ./.cargo +COPY crates ./crates + +RUN cargo build --locked --release -p switchyard-server -# Runtime image: binary only, runs unprivileged. Mount a TOML deployment at -# /etc/switchyard/config.toml and pass provider API keys as env vars. FROM debian:bookworm-slim + RUN apt-get update \ - && apt-get install --yes --no-install-recommends ca-certificates \ - && rm -rf /var/lib/apt/lists/* \ - && useradd --system --uid 10001 switchyard -COPY --from=builder /app/target/release/switchyard-server /usr/local/bin/switchyard-server -USER switchyard + && apt-get install --no-install-recommends -y ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=builder \ + /opt/switchyard/target/release/switchyard-server \ + /usr/local/bin/switchyard-server + +ENV HOME=/tmp + +USER 1000:1000 EXPOSE 4000 + ENTRYPOINT ["switchyard-server"] -CMD ["--config", "/etc/switchyard/config.toml"] diff --git a/benchmark/README.md b/benchmark/README.md index 86feef084..dfaa36a52 100644 --- a/benchmark/README.md +++ b/benchmark/README.md @@ -291,7 +291,7 @@ and while the Rust server is still reachable; otherwise the manifest records the ## Docker Image Notes Baseline runs build `switchyard-baseline:local` from -`benchmark/switchyard-rust-server.Dockerfile`. +the repository-root `Dockerfile`. The default is to rebuild before each run so the container matches the current checkout. To reuse an already built image: diff --git a/benchmark/run-baseline.sh b/benchmark/run-baseline.sh index bcadfc043..b11b6adcf 100755 --- a/benchmark/run-baseline.sh +++ b/benchmark/run-baseline.sh @@ -47,7 +47,7 @@ BOOK_MODE="closed" PROXY_STRIP_ARTIFACT="/etc/proxy-public/strip.jsonl" VERIFIER_PROXY_TEMPLATE='${SWITCHYARD_VERIFIER_HTTP_PROXY}' SWITCHYARD_DOCKER_IMAGE="${SWITCHYARD_DOCKER_IMAGE:-switchyard-baseline:local}" -SWITCHYARD_DOCKERFILE="${SWITCHYARD_DOCKERFILE:-benchmark/switchyard-rust-server.Dockerfile}" +SWITCHYARD_DOCKERFILE="${SWITCHYARD_DOCKERFILE:-Dockerfile}" SWITCHYARD_DOCKER_SERVICE_NAME="${SWITCHYARD_DOCKER_SERVICE_NAME:-switchyard}" SWITCHYARD_DOCKER_BUILD="${SWITCHYARD_DOCKER_BUILD:-1}" SWITCHYARD_DOCKER_NETWORK="${SWITCHYARD_DOCKER_NETWORK:-}" diff --git a/benchmark/switchyard-rust-server.Dockerfile b/benchmark/switchyard-rust-server.Dockerfile deleted file mode 100644 index 8c52b5523..000000000 --- a/benchmark/switchyard-rust-server.Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -ARG RUST_VERSION=1.96.1 -FROM rust:${RUST_VERSION}-bookworm AS builder - -WORKDIR /opt/switchyard -COPY Cargo.toml Cargo.lock ./ -COPY crates ./crates - -RUN cargo build --locked --release -p switchyard-server - -FROM debian:bookworm-slim - -RUN apt-get update \ - && apt-get install --no-install-recommends -y ca-certificates \ - && rm -rf /var/lib/apt/lists/* - -COPY --from=builder \ - /opt/switchyard/target/release/switchyard-server \ - /usr/local/bin/switchyard-server - -ENV HOME=/tmp - -USER 1000:1000 -EXPOSE 4000 - -ENTRYPOINT ["switchyard-server"]