Zoekt index server Dockerfile

This commit is contained in:
bkellam 2024-08-30 18:36:53 -07:00
parent 2069fe6251
commit edb6e1a28f
4 changed files with 72 additions and 0 deletions

View file

@ -0,0 +1,40 @@
FROM golang:1.22.2-alpine3.19 AS builder
RUN apk add --no-cache ca-certificates
WORKDIR /zoekt
COPY vendor/zoekt/go.mod vendor/zoekt/go.sum ./
RUN go mod download
COPY vendor/zoekt ./
RUN CGO_ENABLED=0 GOOS=linux go build -o /cmd/ ./cmd/...
FROM alpine:3.19 AS zoekt
WORKDIR /app
RUN apk add --no-cache git ca-certificates bind-tools tini jansson wget
COPY vendor/zoekt/install-ctags-alpine.sh .
RUN ./install-ctags-alpine.sh && rm install-ctags-alpine.sh
ENV DATA_DIR /zoekt-data/
RUN mkdir -p ${DATA_DIR}
ENV CONFIG_PATH /app/configs/config.json
COPY entrypoint.zoekt-indexserver.sh ./entrypoint.sh
RUN chmod +x ./entrypoint.sh
COPY --from=builder \
/cmd/zoekt-git-index \
/cmd/zoekt-indexserver \
/cmd/zoekt-mirror-github \
/cmd/zoekt-mirror-gitiles \
/cmd/zoekt-mirror-bitbucket-server \
/cmd/zoekt-mirror-gitlab \
/cmd/zoekt-mirror-gerrit \
/usr/local/bin/
ENTRYPOINT ["/sbin/tini", "--", "./entrypoint.sh"]

6
configs/config.json Normal file
View file

@ -0,0 +1,6 @@
[
{
"GithubOrg": "TaqlaAI",
"NoArchived": true
}
]

10
docker-compose.yml Normal file
View file

@ -0,0 +1,10 @@
version: '3'
services:
zoekt-indexserver:
build:
dockerfile: Dockerfile.zoekt-indexserver
environment:
- GITHUB_TOKEN=${GITHUB_TOKEN}
- CONFIG_PATH=/app/configs/config.json
volumes:
- ./configs/config.json:/app/configs/config.json:r

View file

@ -0,0 +1,16 @@
#!/bin/sh
set -e
# Check if GITHUB_TOKEN is set
if [ -n "$GITHUB_TOKEN" ]; then
echo "$GITHUB_TOKEN" > "$HOME/.github-token"
chmod 600 "$HOME/.github-token"
# Configure Git with the provided GITHUB_TOKEN
# @see : https://github.com/sourcegraph/zoekt/issues/578#issuecomment-1519369619
git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/".insteadof "https://github.com"
else
echo -e "\e[33mWarning: Private GitHub repositories will not be indexed since GITHUB_TOKEN was not set. If you are not using GitHub, disregard.\e[0m"
fi
exec "zoekt-indexserver" "-data_dir" "${DATA_DIR}" "-mirror_config" "${CONFIG_PATH}"