# 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"]