diff --git a/mcp-servers/go/benchmark-server/Dockerfile b/mcp-servers/go/benchmark-server/Dockerfile index 6cd15bd7e..4a606db6e 100644 --- a/mcp-servers/go/benchmark-server/Dockerfile +++ b/mcp-servers/go/benchmark-server/Dockerfile @@ -1,4 +1,6 @@ -FROM --platform=$TARGETPLATFORM golang:1.23 AS builder +# This build supports multi-platform builds through standard Docker Buildx +# techniques, including the $TARGETPLATFORM environment variable. +FROM golang:1.23 AS builder WORKDIR /src COPY go.mod . RUN go mod download @@ -7,4 +9,5 @@ RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags "-s -w" -o /usr/local/b FROM scratch COPY --from=builder /usr/local/bin/benchmark-server /benchmark-server +USER 1001:1001 ENTRYPOINT ["/benchmark-server"] diff --git a/mcp-servers/go/fast-time-server/Dockerfile b/mcp-servers/go/fast-time-server/Dockerfile index 0063bf887..037c12cea 100644 --- a/mcp-servers/go/fast-time-server/Dockerfile +++ b/mcp-servers/go/fast-time-server/Dockerfile @@ -8,12 +8,15 @@ # Build: docker build -t fast-time-server:latest --build-arg VERSION=$(git rev-parse --short HEAD) . # Run : docker run --rm -p 8080:8080 fast-time-server:latest # # now visit http://localhost:8080/sse or http://localhost:8080/http +# +# This build supports multi-platform builds through standard Docker Buildx +# techniques, including the $TARGETPLATFORM environment variable. # ============================================================================= # ============================================================================= # 🏗️ STAGE 1 - BUILD STATIC BINARY (Go 1.23, CGO disabled) # ============================================================================= -FROM --platform=$TARGETPLATFORM golang:1.23 AS builder +FROM golang:1.23 AS builder WORKDIR /src COPY go.mod go.sum ./ @@ -31,7 +34,7 @@ RUN CGO_ENABLED=0 GOOS=linux go build \ # 📦 STAGE 2 - MINIMAL RUNTIME (scratch + tzdata + binary) # ============================================================================= FROM scratch -LABEL org.opencontainers.image.source https://github.com/IBM/mcp-context-forge +LABEL org.opencontainers.image.source=https://github.com/IBM/mcp-context-forge # copy tzdata so time.LoadLocation works COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo @@ -40,5 +43,6 @@ COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo COPY --from=builder /usr/local/bin/fast-time-server /fast-time-server # --- default: SSE + HTTP on 8080 --- +USER 1001:1001 ENTRYPOINT ["/fast-time-server"] CMD ["-transport=dual", "-port=8080", "-listen=0.0.0.0"] diff --git a/mcp-servers/templates/go/Dockerfile.jinja b/mcp-servers/templates/go/Dockerfile.jinja index d0628ae54..47048d750 100644 --- a/mcp-servers/templates/go/Dockerfile.jinja +++ b/mcp-servers/templates/go/Dockerfile.jinja @@ -1,6 +1,9 @@ # Multi-stage container for {{ project_name }} -FROM --platform=$TARGETPLATFORM golang:{{ go_version }} AS builder +# This build supports multi-platform builds through standard Docker Buildx +# techniques, including the $TARGETPLATFORM environment variable. + +FROM golang:{{ go_version }} AS builder WORKDIR /src COPY go.mod . @@ -10,9 +13,10 @@ COPY . . RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags "-s -w" -o /usr/local/bin/{{ bin_name }} . FROM scratch -LABEL org.opencontainers.image.source https://github.com/contextforge/mcp-context-forge +LABEL org.opencontainers.image.source=https://github.com/contextforge/mcp-context-forge COPY --from=builder /usr/local/bin/{{ bin_name }} /{{ bin_name }} +USER 1001:1001 ENTRYPOINT ["/{{ bin_name }}"]