v1.12 track B.1: codecontext sidecar container + HTTP shim
New /opt/boocode/codecontext/ directory holding the codecontext sidecar that BooCode's tool wrappers (track B.2) will talk to. No BooCode-side changes yet — this commit lands the sidecar standalone. - Dockerfile: multi-stage golang:1.24-alpine → alpine:3.20. Clones codecontext at v3.2.1 from github.com/nmakod/codecontext (cgo build for tree-sitter bindings), builds the shim alongside (CGO_ENABLED=0). - shim.go: stdlib-only Go HTTP server wrapping codecontext's stdio MCP child. Newline-delimited JSON framing per the MCP transport spec (NOT LSP-style Content-Length). 8 POST /v1/* endpoints, one per MCP tool, plus GET /health. Child supervised via child.Wait() goroutine that os.Exit's on death so the container's restart: unless-stopped policy fires (Signal(0) on a zombie returns nil and is not a liveness check — discovered during kill-restart testing). - go.mod: no third-party deps; future Go security advisories don't apply. docker-compose service: joins boocode_net (no host port), mounts /opt:/opt:ro (BooCode projects live at /opt/<slug>, not exclusively under /opt/projects), healthcheck on /health. Verified: build clean, healthcheck reports healthy ~15s after up, multi-project queries return valid markdown, target_dir swap works on subtree paths. Kill-restart cycle completes in ~200ms with one failed health poll observed (no misleading "ok" during the gap). Memory: 24.6 MiB after 5 search_symbols calls, 5.6 MiB after 30 min idle — codecontext releases the per-call graph between target_dir swaps, so the shim doesn't hold the indexed state.
This commit is contained in:
40
codecontext/Dockerfile
Normal file
40
codecontext/Dockerfile
Normal file
@@ -0,0 +1,40 @@
|
||||
# v1.12 Track B — codecontext sidecar container.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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.
|
||||
|
||||
FROM golang:1.24-alpine AS builder
|
||||
WORKDIR /build
|
||||
|
||||
RUN apk add --no-cache git ca-certificates build-base
|
||||
|
||||
# Build codecontext from the v3.2.1 tag.
|
||||
# CGO is required: codecontext binds tree-sitter via cgo.
|
||||
RUN git clone --depth=1 --branch v3.2.1 https://github.com/nmakod/codecontext.git /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.
|
||||
WORKDIR /build/shim
|
||||
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.
|
||||
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
|
||||
|
||||
EXPOSE 8080
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s \
|
||||
CMD wget -qO- http://localhost:8080/health || exit 1
|
||||
ENTRYPOINT ["/usr/local/bin/shim"]
|
||||
Reference in New Issue
Block a user