Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions wish/cpp/Dockerfile.benchmark
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,27 @@ COPY patches/ patches/
COPY src/ src/
COPY benchmark/ benchmark/

# Configure: triggers FetchContent downloads (cached as a Docker layer).
RUN cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DWISH_BUILD_TESTS=OFF \
-DWISH_BUILD_BENCHMARKS=ON \
-DWISH_BUILD_EXAMPLES=OFF

RUN cmake --build build \
--target benchmark_client tls_benchmark_client high_qps_benchmark_client \
-- -j"$(nproc)"
# Two persistent BuildKit cache volumes:
# /cmake-cache – FetchContent downloads (git repos, tarballs)
# /cmake-build – full cmake build tree (object files, compiled libs)
# Both survive Docker layer invalidations; only changed sources are
# recompiled on subsequent builds.
# The binary is copied into the image layer at the end of the step.
RUN --mount=type=cache,target=/cmake-cache,sharing=locked \
--mount=type=cache,target=/cmake-build,sharing=locked \
cmake -S . -B /cmake-build -G Ninja \
-DFETCHCONTENT_BASE_DIR=/cmake-cache \
-DCMAKE_BUILD_TYPE=Release \
-DWISH_BUILD_TESTS=OFF \
-DWISH_BUILD_BENCHMARKS=ON \
-DWISH_BUILD_EXAMPLES=OFF \
&& cmake --build /cmake-build \
--target benchmark_client tls_benchmark_client high_qps_benchmark_client \
-- -j"$(nproc)" \
&& mkdir -p build \
&& cp /cmake-build/benchmark/benchmark_client build/benchmark_client \
&& cp /cmake-build/benchmark/tls_benchmark_client build/tls_benchmark_client \
&& cp /cmake-build/benchmark/high_qps_benchmark_client build/high_qps_benchmark_client

# ---------------------------------------------------------------------------
# Stage 2: Runtime
Expand All @@ -44,9 +55,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libstdc++6 \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /src/build/benchmark/benchmark_client /usr/local/bin/benchmark_client
COPY --from=builder /src/build/benchmark/tls_benchmark_client /usr/local/bin/tls_benchmark_client
COPY --from=builder /src/build/benchmark/high_qps_benchmark_client /usr/local/bin/high_qps_benchmark_client
COPY --from=builder /src/build/benchmark_client /usr/local/bin/benchmark_client
COPY --from=builder /src/build/tls_benchmark_client /usr/local/bin/tls_benchmark_client
COPY --from=builder /src/build/high_qps_benchmark_client /usr/local/bin/high_qps_benchmark_client
Comment on lines +58 to +60
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed path


# Default: latency benchmark client.
# Override the ENTRYPOINT or CMD in the Job spec to switch clients.
Expand Down
34 changes: 22 additions & 12 deletions wish/cpp/Dockerfile.echo_server
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,26 @@ COPY patches/ patches/
COPY src/ src/
COPY examples/ examples/

# Configure: triggers FetchContent downloads (cached as a Docker layer).
RUN cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DWISH_BUILD_TESTS=OFF \
-DWISH_BUILD_BENCHMARKS=OFF \
-DWISH_BUILD_EXAMPLES=ON

RUN cmake --build build \
--target echo_server tls_echo_server \
-- -j"$(nproc)"
# Two persistent BuildKit cache volumes:
# /cmake-cache – FetchContent downloads (git repos, tarballs)
# /cmake-build – full cmake build tree (object files, compiled libs)
# Both survive Docker layer invalidations; only changed sources are
# recompiled on subsequent builds.
# The binary is copied into the image layer at the end of the step.
RUN --mount=type=cache,target=/cmake-cache,sharing=locked \
--mount=type=cache,target=/cmake-build,sharing=locked \
cmake -S . -B /cmake-build -G Ninja \
-DFETCHCONTENT_BASE_DIR=/cmake-cache \
-DCMAKE_BUILD_TYPE=Release \
-DWISH_BUILD_TESTS=OFF \
-DWISH_BUILD_BENCHMARKS=OFF \
-DWISH_BUILD_EXAMPLES=ON \
&& cmake --build /cmake-build \
--target echo_server tls_echo_server \
-- -j"$(nproc)" \
&& mkdir -p build \
&& cp /cmake-build/examples/echo_server build/echo_server \
&& cp /cmake-build/examples/tls_echo_server build/tls_echo_server

# ---------------------------------------------------------------------------
# Stage 2: Runtime
Expand All @@ -44,8 +54,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libstdc++6 \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /src/build/examples/echo_server /usr/local/bin/echo_server
COPY --from=builder /src/build/examples/tls_echo_server /usr/local/bin/tls_echo_server
COPY --from=builder /src/build/echo_server /usr/local/bin/echo_server
COPY --from=builder /src/build/tls_echo_server /usr/local/bin/tls_echo_server
Comment on lines +57 to +58
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed path


EXPOSE 8080

Expand Down
11 changes: 8 additions & 3 deletions wish/cpp/scripts/build-and-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
# (or: gcloud auth login && gcloud auth application-default login)
#
# Usage:
# cd wish/cpp
# REGION=asia-northeast1 PROJECT=my-gcp-project REPOSITORY=wish ./scripts/build-and-push.sh
#
# Optional env vars:
# TAG – image tag (default: git short SHA or "latest")
# PUSH – set to "false" to build only without pushing
# FRESH – set to "true" to bypass all caches (re-downloads FetchContent deps)

set -euo pipefail

Expand All @@ -30,14 +30,16 @@ else
fi
TAG="${TAG:-${DEFAULT_TAG}}"
PUSH="${PUSH:-true}"
FRESH="${FRESH:-false}"

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# The build context is wish/cpp (one level above scripts/).
# The build context is one level above scripts/.
CTX="$(cd "${SCRIPT_DIR}/.." && pwd)"

echo "==> Build context : ${CTX}"
echo "==> Registry : ${REGISTRY}"
echo "==> Tag : ${TAG}"
echo "==> Fresh build : ${FRESH}"
echo ""

build_and_push() {
Expand All @@ -47,10 +49,13 @@ build_and_push() {
local latest_tag="${REGISTRY}/${name}:latest"

echo "==> Building ${full_tag} ..."
local extra_flags=()
[[ "${FRESH}" == "true" ]] && extra_flags+=(--no-cache)
DOCKER_BUILDKIT=1 docker build \
--file "${CTX}/${dockerfile}" \
--tag "${full_tag}" \
--tag "${latest_tag}" \
"${extra_flags[@]}" \
"${CTX}"

if [[ "${PUSH}" == "true" ]]; then
Expand All @@ -60,5 +65,5 @@ build_and_push() {
fi
}

build_and_push "echo-server" "Dockerfile.echo_server"
build_and_push "echo-server" "Dockerfile.echo_server"
build_and_push "benchmark" "Dockerfile.benchmark"