-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (48 loc) · 2.05 KB
/
Dockerfile
File metadata and controls
67 lines (48 loc) · 2.05 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
57
58
59
60
61
62
63
64
65
66
67
# Stage 1: Build Zoekt binaries from source
FROM golang:1.24-alpine AS zoekt-builder
RUN apk add --no-cache git
# Pin to a specific commit for reproducible builds
ARG ZOEKT_VERSION=c747a3bccc2a4a427204ac08eea62a522df6d2ec
RUN git clone https://github.com/sourcegraph/zoekt.git /zoekt && \
cd /zoekt && \
git checkout ${ZOEKT_VERSION}
WORKDIR /zoekt
RUN CGO_ENABLED=0 go build -o /out/zoekt-index ./cmd/zoekt-index && \
CGO_ENABLED=0 go build -o /out/zoekt-webserver ./cmd/zoekt-webserver
# Stage 2: Install Node.js dependencies with native compilation
FROM node:22-slim AS node-builder
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential python3 && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev
# Stage 3: Runtime image
FROM node:22-slim
RUN apt-get update && \
apt-get install -y --no-install-recommends tini lsof procps && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy Zoekt binaries
COPY --from=zoekt-builder /out/zoekt-index /usr/local/bin/zoekt-index
COPY --from=zoekt-builder /out/zoekt-webserver /usr/local/bin/zoekt-webserver
# Copy node_modules from builder
COPY --from=node-builder /app/node_modules ./node_modules
# Copy application source
COPY package.json ./
COPY src ./src
COPY config.docker.json ./config.docker.json
COPY docker-entrypoint.sh ./docker-entrypoint.sh
# Bake git hash into image for version tracking (passed via --build-arg)
ARG BUILD_GIT_HASH=unknown
RUN echo "${BUILD_GIT_HASH}" > /app/.git-hash
# Fix Windows CRLF line endings (build context may come from Windows filesystem)
RUN sed -i 's/\r$//' ./docker-entrypoint.sh && chmod +x ./docker-entrypoint.sh
# Create data directories
RUN mkdir -p /data/db /data/mirror /data/zoekt-index
ENV INSIDE_CONTAINER=1
EXPOSE 3847
HEALTHCHECK --interval=15s --timeout=5s --start-period=60s --retries=3 \
CMD node -e "fetch('http://localhost:3847/health').then(r => { if (!r.ok) process.exit(1) }).catch(() => process.exit(1))"
ENTRYPOINT ["tini", "--"]
CMD ["./docker-entrypoint.sh"]