Container images for the Tangled Knot and Spindle servers
1FROM golang:alpine AS build
2FROM alpine AS runtime
3
4FROM build AS tangled
5# earliest version with knot & spindle
6ARG TANGLED_VERSION=v1.6.0-alpha
7ENV URL=https://tangled.org/tangled.org/core/archive/${TANGLED_VERSION}
8RUN wget -O '-' $URL | tar -zxvf '-'
9RUN mv core-${TANGLED_VERSION} /core
10WORKDIR /core
11RUN go mod download
12
13FROM build AS build-spindle
14WORKDIR /app
15COPY --from=tangled /core .
16RUN go build -o spindle cmd/spindle/main.go
17
18FROM build AS build-knot
19WORKDIR /app
20COPY --from=tangled /core .
21RUN go build -o knot cmd/knot/main.go
22
23FROM runtime AS spindle
24ENV SPINDLE_SERVER_DB_PATH=/var/lib/spindle/spindle.db
25RUN addgroup --system --gid 1001 spindle
26RUN adduser --system --uid 1001 spindle
27RUN mkdir -p /var/{lib,log}/spindle
28COPY --from=build_spindle /app/spindle /usr/bin/spindle
29EXPOSE 6555
30USER spindle
31VOLUME ["/var/log/spindle", "/var/lib/spindle"]
32CMD ["spindle"]
33
34FROM runtime AS knot
35ARG UID=1001
36ARG GID=1001
37ENV KNOT_SERVER_DB_PATH=/home/git/knotserver.db
38ENV KNOT_REPO_SCAN_PATH=/home/git/repositories
39ENV KNOT_SERVER_INTERNAL_LISTEN_ADDR=localhost:5444
40COPY knot .
41RUN chmod 755 /etc
42RUN chmod -R 755 /etc/s6-overlay
43RUN apk add shadow s6-overlay execline openssl openssh git curl bash
44RUN groupadd -g $GID -f git
45RUN useradd -u $UID -g $GID -d /home/git git
46RUN openssl rand -hex 16 | passwd --stdin git
47RUN mkdir -p /home/git/repositories && chown -R git:git /home/git
48COPY --from=build_knot /app/knot /usr/bin/knot
49EXPOSE 5555
50EXPOSE 22
51USER git
52WORKDIR /home/git
53VOLUME ["/home/git", "/etc/ssh/keys"]
54ENTRYPOINT ["/init"]
55HEALTHCHECK --interval=60s --timeout=30s --start-period=5s --retries=3 \
56 CMD curl -f http://localhost:5555 || exit 1