diff --git a/Dockerfile.zoekt-indexserver b/Dockerfile.zoekt-indexserver new file mode 100644 index 00000000..f920f1d8 --- /dev/null +++ b/Dockerfile.zoekt-indexserver @@ -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"] diff --git a/configs/config.json b/configs/config.json new file mode 100644 index 00000000..769db6ba --- /dev/null +++ b/configs/config.json @@ -0,0 +1,6 @@ +[ + { + "GithubOrg": "TaqlaAI", + "NoArchived": true + } +] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..be6520ba --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/entrypoint.zoekt-indexserver.sh b/entrypoint.zoekt-indexserver.sh new file mode 100644 index 00000000..2d89ddcb --- /dev/null +++ b/entrypoint.zoekt-indexserver.sh @@ -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}"