forked from
tangled.org/knot-docker
Docker config for @recaptime.dev's Knot server on Hack Club Nest.
knot.hackclub.community
1ARG BUILDER_IMAGE=golang:1.25-alpine
2ARG DEPLOY_IMAGE=alpine:edge
3FROM ${BUILDER_IMAGE} as builder
4ENV KNOT_REPO_SCAN_PATH=/home/git/repositories
5ENV CGO_ENABLED=1 GOSUMDB=off GOPROXY=direct
6
7ARG KNOT_RELEASE_TAG='v1.13.0-alpha' KNOT_REPO_URL=https://tangled.org/@tangled.org/core
8
9WORKDIR /app
10RUN apk add git gcc musl-dev
11RUN git clone -b ${KNOT_RELEASE_TAG} ${KNOT_REPO_URL} . \
12 && go build -o /usr/bin/knot -ldflags '-s -w -extldflags "-static"' ./cmd/knot \
13 && git rev-parse HEAD > commit-sha.txt
14
15FROM ${DEPLOY_IMAGE} as deploy
16EXPOSE 5555
17EXPOSE 22
18
19ARG DOCKER_BUILD_COMMIT
20ARG DOCKER_BUILD_REPO=https://gitlab.com/recaptime-dev/infra/docker/tangled-knotserver
21
22LABEL org.opencontainers.image.title='Knot data server for Tangled (Recap Time Squad image distribution)' \
23 org.opencontainers.image.description="Tangled's data server for hosting Git repositories in the Atmosphere" \
24 org.opencontainers.image.source=${DOCKER_BUILD_REPO} \
25 org.opencontainers.image.url='https://tangled.org' \
26 org.opencontainers.image.vendor='Recap Time Squad' \
27 org.opencontainers.image.authors="Andrei Jiroh Halili <ajhalili2006@crew.recaptime.dev>" \
28 org.opencontainers.image.licenses='MIT' \
29 org.opencontainers.image.revision=${DOCKER_BUILD_COMMIT} \
30 org.opencontainers.image.documentation='https://docs.tangled.org/knot-self-hosting-guide.html'
31
32ENV TANGLED_REPO_URL=${KNOT_REPO_URL} DOCKER_BUILD_COMMIT=${DOCKER_BUILD_COMMIT} DOCKER_BUILD_REPO=${DOCKER_BUILD_REPO} KNOT_REPO_SCAN_PATH=/home/git/repositories
33
34ARG UID=1000
35ARG GID=1000
36
37COPY rootfs .
38COPY motd.txt /home/git/motd
39
40RUN chmod 755 /etc && chmod -R 755 /etc/s6-overlay \
41 && apk add shadow s6-overlay execline openssl openssh git curl bash \
42 && groupadd -g $GID -f git \
43 && useradd -u $UID -g $GID -d /home/git git \
44 && openssl rand -hex 16 | passwd --stdin git \
45 && mkdir -p /home/git/repositories && chown -R git:git /home/git \
46 && mkdir /app && chown -R git:git /app \
47 && chown git:git /home/git/motd
48
49COPY --from=builder /usr/bin/knot /usr/bin
50COPY --from=builder /app/commit-sha.txt /opt/knotserver-commit-sha
51
52HEALTHCHECK --interval=60s --timeout=30s --start-period=5s --retries=3 \
53 CMD curl -f http://localhost:5555 || exit 1
54
55ENTRYPOINT ["/init"]