Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (43 loc) · 2.03 KB
/
Copy pathDockerfile
File metadata and controls
56 lines (43 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# CPU image. Runs the local embedding provider on the pure-Go compute backend, or
# on XLA-CPU if the plugin is installed at runtime.
#
# Model weights are NOT baked in: bge-small-en-v1.5 alone is 133 MB, and which
# model you want is a configuration decision. Mount the cache instead:
#
# docker build -t codamigo:cpu .
# docker run --rm -v ~/.codamigo/models:/root/.codamigo/models codamigo:cpu doctor
#
# A builder stage with a C toolchain is mandatory. CGO_ENABLED=0 is not an option
# here: mattn/go-sqlite3 and the tree-sitter grammars in go-code-chunker are both
# cgo, so a static pure-Go build cannot work.
FROM golang:1.26.5-bookworm AS builder
ENV CGO_ENABLED=1
# libsqlite3-dev supplies sqlite3.h, which sqlite-vec's own C sources include.
# The golang image ships gcc but no SQLite headers, so without this the build
# fails with "sqlite-vec.h:7:10: fatal error: sqlite3.h: No such file or
# directory". It is easy to miss on macOS, where the SDK provides the header.
RUN apt-get update \
&& apt-get install -y --no-install-recommends libsqlite3-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
# Copy the module files first so dependency download is cached independently of
# source changes.
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# sqlite_fts5 enables FTS5, which the BM25 half of hybrid search depends on.
RUN go build -tags sqlite_fts5 -o /out/codamigo ./cmd/codamigo/
FROM debian:bookworm-slim
# ca-certificates is needed by `codamigo download-model`; libgomp1 is the OpenMP
# runtime the XLA CPU plugin links against if one is mounted in.
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates libgomp1 \
&& rm -rf /var/lib/apt/lists/*
# Fail fast to the pure-Go backend rather than reaching for GitHub mid-run if no
# PJRT plugin is present. Installing one is an explicit `download-model --xla`.
ENV GOMLX_NO_AUTO_INSTALL=1
COPY --from=builder /out/codamigo /usr/local/bin/codamigo
# The project being indexed is mounted here.
WORKDIR /work
ENTRYPOINT ["codamigo"]
CMD ["doctor"]