feat(codecontext): upgrade sidecar to boocontext MCP aggregator
- Multi-stage Dockerfile builds boocontext (Node) + HTTP shim (Go) - shim.go supports CODECONTEXT_CHILD env var for configurable MCP child - Adds routes for get_symbol_details, get_call_graph, get_blast_radius - docker-compose.yml adds env vars for child MCP paths
This commit is contained in:
@@ -1,41 +1,38 @@
|
||||
# v1.12 Track B — codecontext sidecar container.
|
||||
# v2.8 — boocontext sidecar container.
|
||||
# Multi-stage build: Go shim from golang:1.24-alpine, boocontext MCP aggregator
|
||||
# from node:20-alpine, then an alpine:3.20 runtime holding both.
|
||||
#
|
||||
# Multi-stage build: golang:1.24-alpine builder produces two binaries
|
||||
# (codecontext from source + our HTTP shim), then a minimal alpine:3.20
|
||||
# runtime holds both.
|
||||
# The shim spawns boocontext as a child MCP process over stdio NDJSON,
|
||||
# translating HTTP requests to MCP tools/call.
|
||||
#
|
||||
# No upstream Docker image exists for codecontext. We clone the repo
|
||||
# directly because the module path declared in go.mod
|
||||
# (github.com/nuthan-ms/codecontext) differs from the GitHub repo URL
|
||||
# (github.com/nmakod/codecontext) — `go install` against the GitHub path
|
||||
# wouldn't resolve. The tagged v3.2.1 source tree is the same either way.
|
||||
# To stage the fork source for a Docker build:
|
||||
# tar -czf codecontext/fork.tar.gz -C /opt/forks/boocontext \
|
||||
# --exclude=.git --exclude=node_modules --exclude=dist
|
||||
|
||||
FROM golang:1.24-alpine AS builder
|
||||
WORKDIR /build
|
||||
|
||||
RUN apk add --no-cache git ca-certificates build-base
|
||||
|
||||
# Build codecontext from the boocode-ts fork (has .codecontextignore support).
|
||||
# Source is staged into the build context by the pre-build step:
|
||||
# tar -czf codecontext/fork.tar.gz -C /opt/forks/codecontext .
|
||||
# CGO is required: codecontext binds tree-sitter via cgo.
|
||||
COPY fork.tar.gz /build/fork.tar.gz
|
||||
RUN mkdir -p /build/codecontext && tar -xzf /build/fork.tar.gz -C /build/codecontext
|
||||
WORKDIR /build/codecontext
|
||||
RUN CGO_ENABLED=1 GOOS=linux go build -o /build/codecontext-bin ./cmd/codecontext
|
||||
|
||||
# Build the shim. Stdlib-only — no go.sum needed.
|
||||
# Stage 1: Go shim builder
|
||||
FROM golang:1.24-alpine AS shim-builder
|
||||
WORKDIR /build/shim
|
||||
RUN apk add --no-cache ca-certificates
|
||||
COPY go.mod ./
|
||||
COPY shim.go ./
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o /build/shim-bin ./
|
||||
|
||||
# Runtime: alpine matches the build target so codecontext's cgo bindings
|
||||
# resolve against the same musl libc.
|
||||
# Stage 2: boocontext MCP builder
|
||||
FROM node:20-alpine AS boocontext-builder
|
||||
WORKDIR /build/boocontext
|
||||
RUN apk add --no-cache git python3 make g++ ca-certificates
|
||||
COPY fork.tar.gz /build/fork.tar.gz
|
||||
RUN mkdir -p /build/boocontext && tar -xzf /build/fork.tar.gz -C /build/boocontext
|
||||
WORKDIR /build/boocontext
|
||||
RUN npm ci && npm run build
|
||||
|
||||
# Stage 3: Runtime
|
||||
FROM alpine:3.20
|
||||
RUN apk add --no-cache ca-certificates
|
||||
COPY --from=builder /build/codecontext-bin /usr/local/bin/codecontext
|
||||
COPY --from=builder /build/shim-bin /usr/local/bin/shim
|
||||
RUN apk add --no-cache ca-certificates nodejs uv
|
||||
COPY --from=shim-builder /build/shim-bin /usr/local/bin/shim
|
||||
COPY --from=boocontext-builder /build/boocontext/dist /usr/local/lib/boocontext/dist
|
||||
COPY --from=boocontext-builder /build/boocontext/node_modules /usr/local/lib/boocontext/node_modules
|
||||
COPY --from=boocontext-builder /build/boocontext/package.json /usr/local/lib/boocontext/package.json
|
||||
|
||||
EXPOSE 8080
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s \
|
||||
|
||||
Reference in New Issue
Block a user