Community maintained Docker config for the knot server

add build stage for the spindle server

authored by psychedeli.ca and committed by bas.sh d745f839 c0816c02

verified
+34 -5
+34 -5
Dockerfile
··· 1 1 from golang:1.25-alpine as builder 2 - env KNOT_REPO_SCAN_PATH=/home/git/repositories 3 2 env CGO_ENABLED=1 4 3 5 4 arg TAG='v1.11.0-alpha' ··· 7 6 workdir /app 8 7 run apk add git gcc musl-dev 9 8 run git clone -b ${TAG} https://tangled.org/@tangled.org/core . 10 - run go build -o /usr/bin/knot -ldflags '-s -w -extldflags "-static"' ./cmd/knot 11 9 12 - from alpine:latest 10 + FROM builder AS build-knot 11 + RUN go build -o /usr/bin/knot -ldflags '-s -w -extldflags "-static"' ./cmd/knot 12 + 13 + FROM builder AS build-spindle 14 + RUN go build -o /usr/bin/spindle ./cmd/spindle 15 + 16 + from alpine:latest AS knot 17 + ENV KNOT_REPO_SCAN_PATH=/home/git/repositories 13 18 expose 5555 14 19 expose 22 15 20 ··· 31 36 run useradd -u $UID -g $GID -d /home/git git 32 37 run openssl rand -hex 16 | passwd --stdin git 33 38 run mkdir -p /home/git/repositories && chown -R git:git /home/git 34 - copy --from=builder /usr/bin/knot /usr/bin 39 + copy --from=build-knot /usr/bin/knot /usr/bin 35 40 run mkdir /app && chown -R git:git /app 36 41 37 42 healthcheck --interval=60s --timeout=30s --start-period=5s --retries=3 \ 38 43 cmd curl -f http://localhost:5555 || exit 1 44 + entrypoint ["/init"] 39 45 40 - entrypoint ["/init"] 46 + FROM alpine:edge AS spindle 47 + EXPOSE 6555 48 + 49 + LABEL org.opencontainers.image.title="spindle" 50 + LABEL org.opencontainers.image.description="ci server for tangled" 51 + LABEL org.opencontainers.image.source="https://tangled.org/@tangled.org/knot-docker" 52 + LABEL org.opencontainers.image.url="https://tangled.org" 53 + LABEL org.opencontainers.image.vendor="tangled.org" 54 + LABEL org.opencontainers.image.licenses="MIT" 55 + 56 + ARG UID=1000 57 + ARG GID=1000 58 + 59 + RUN groupadd --system -g $GID -f spindle 60 + RUN useradd --system -u $UID -g $GID spindle 61 + RUN mkdir -p /app && chown -R spindle:spindle /app 62 + 63 + COPY --from=build-spindle /usr/bin/spindle /usr/bin 64 + 65 + WORKDIR /app 66 + CMD ["spindle"] 67 + VOLUME ["/app"] 68 + HEALTHCHECK --interval=60s --timeout=30s --start-period=5s --retries=3 \ 69 + CMD curl -f http://localhost:6555 || exit 1