Skip to content

Commit f615207

Browse files
committed
fix(fast-time-server): build container image from Cargo workspace root
The crate's Cargo.toml uses workspace inheritance (.workspace = true) for every package field and dependency. The previous Containerfile copied only the crate-local Cargo.toml into the build context, which caused cargo to fail with 'failed to find a workspace root' (exit 101) the moment PR #5305 added this crate to the root workspace. Rewrite the Containerfile to copy the root Cargo.toml/Cargo.lock and the workspace members (crates/, a2a-agents/, mcp-servers/rust/), then build with 'cargo build --release -p fast-time-server'. The build now runs from the repo root; see the compose and Makefile changes in sibling commits for the matching wiring. Also remove the orphan Dockerfile: it had the identical bug, no consumers in the repo (no Makefile, compose, CI, or Helm reference it), and an inconsistent port (8880 vs the 9080 the README documents). Add Containerfile to the .dockerignore allow-list for parity with the slow-time-server pattern. Signed-off-by: Jonathan Springer <jps@s390x.com> (cherry picked from commit 6034102)
1 parent 2edc3e4 commit f615207

3 files changed

Lines changed: 21 additions & 78 deletions

File tree

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ attic/
3535
!mcp-servers/rust/fast-time-server/Cargo.toml
3636
!mcp-servers/rust/fast-time-server/src/
3737
!mcp-servers/rust/fast-time-server/src/**
38+
!mcp-servers/rust/fast-time-server/Containerfile
3839
!mcp-servers/rust/filesystem-server/
3940
!mcp-servers/rust/filesystem-server/Cargo.toml
4041
!mcp-servers/rust/filesystem-server/src/

mcp-servers/rust/fast-time-server/Containerfile

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
11
# syntax=docker/dockerfile:1
22
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
33
# fast-time-server - Ultra-fast MCP server in Rust for performance testing
4-
# Multi-stage build for minimal image size (~15MB)
4+
#
5+
# This image is built from the workspace root so the crate's `Cargo.toml`
6+
# can resolve `.workspace = true` inheritance from the root manifest.
7+
#
8+
# Build (from the repo root):
9+
# docker build -f mcp-servers/rust/fast-time-server/Containerfile -t IMG .
10+
#
11+
# Or via the crate's Makefile (handles the relative path automatically):
12+
# cd mcp-servers/rust/fast-time-server && make container-build
513
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
614

715
# =============================================================================
8-
# Build stage - Rust compilation
16+
# Build stage - Rust compilation against the full Cargo workspace
917
# =============================================================================
1018
FROM docker.io/rustlang/rust:nightly-slim AS builder
1119

1220
WORKDIR /app
1321

14-
# Install build dependencies
1522
RUN apt-get update && apt-get install -y --no-install-recommends \
16-
pkg-config \
23+
pkg-config \
1724
&& rm -rf /var/lib/apt/lists/*
1825

19-
# Copy manifests first for dependency caching
20-
COPY Cargo.toml Cargo.lock* ./
26+
# Copy the Cargo workspace. All members declared in the root manifest must
27+
# exist on disk for `cargo build -p ...` to parse the workspace, even though
28+
# only fast-time-server and its transitive deps actually get compiled.
29+
COPY Cargo.toml Cargo.lock ./
30+
COPY crates ./crates
31+
COPY a2a-agents ./a2a-agents
32+
COPY mcp-servers/rust ./mcp-servers/rust
2133

22-
# Create dummy src to cache dependencies (Docker layer caching optimization)
23-
RUN mkdir src && echo "fn main() {}" > src/main.rs
24-
RUN cargo build --release && rm -rf src target/release/deps/fast_time_server* target/release/.fingerprint/fast-time-server*
25-
26-
# Copy actual source
27-
COPY src ./src
28-
29-
# Build release binary (touch to ensure mtime is newer than cached artifacts)
30-
RUN touch src/main.rs && cargo build --release
34+
RUN cargo build --release -p fast-time-server
3135

3236
# =============================================================================
33-
# Runtime stage - Minimal distroless-like image
37+
# Runtime stage - Minimal Debian image with just the compiled binary
3438
# =============================================================================
3539
FROM docker.io/library/debian:trixie-slim
3640

37-
# Install runtime deps (ca-certificates + curl for health checks) and create
38-
# the non-root mcpuser in a single layer.
3941
RUN apt-get update && apt-get install -y --no-install-recommends \
4042
ca-certificates \
4143
curl \
@@ -45,26 +47,21 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
4547

4648
WORKDIR /app
4749

48-
# Copy binary from builder
4950
COPY --from=builder /app/target/release/fast-time-server /app/fast-time-server
5051

5152
USER mcpuser
5253

53-
# Expose default port
5454
EXPOSE 9080
5555

56-
# Environment configuration
5756
ENV BIND_ADDRESS=0.0.0.0:9080
5857
ENV RUST_LOG=info
5958

60-
# Labels for container registry
6159
LABEL org.opencontainers.image.title="fast-time-server"
6260
LABEL org.opencontainers.image.description="Ultra-fast MCP server in Rust for performance testing"
6361
LABEL org.opencontainers.image.source="https://github.com/IBM/mcp-context-forge"
6462
LABEL org.opencontainers.image.vendor="IBM"
6563
LABEL org.opencontainers.image.licenses="Apache-2.0"
6664

67-
# Health check using curl (more reliable than wget in slim images)
6865
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
6966
CMD curl -sf http://localhost:9080/health || exit 1
7067

mcp-servers/rust/fast-time-server/Dockerfile

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)