Community maintained Docker config for the spindle server

all: fix authorized-keys & add config options

Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.sh>

anirudh.fi 4e66ee74 9533f374

verified
Changed files
+24 -7
rootfs
etc
s6-overlay
scripts
ssh
sshd_config.d
+9 -2
Dockerfile
···
FROM docker.io/golang:1.24-alpine3.21 AS build
ENV CGO_ENABLED=1
+
ENV KNOT_REPO_SCAN_PATH=/home/git/repositories
WORKDIR /usr/src/app
COPY go.mod go.sum ./
···
LABEL org.opencontainers.image.url=https://tangled.sh
LABEL org.opencontainers.image.source=https://tangled.sh/@tangled.sh/core
-
RUN apk add --no-cache shadow s6-overlay execline openssh git && \
+
RUN apk add --no-cache shadow s6-overlay execline openssh git curl && \
adduser --disabled-password git && \
# We need to set password anyway since otherwise ssh won't work
head -c 32 /dev/random | base64 | tr -dc 'a-zA-Z0-9' | passwd git --stdin && \
···
COPY --from=build /usr/local/bin/knot /usr/local/bin
COPY docker/rootfs/ .
+
RUN chmod +x /etc/s6-overlay/scripts/keys-wrapper && \
+
chown git:git /app && \
+
chown -R git:git /home/git/repositories
EXPOSE 22
EXPOSE 5555
-
ENTRYPOINT ["/bin/sh", "-c", "chown git:git /app && chown git:git /home/git/repositories && /init"]
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
+
CMD curl -f http://localhost:5555/ || exit 1
+
+
ENTRYPOINT ["/init"]
+6 -4
docker-compose.yml
···
KNOT_SERVER_SECRET: ${KNOT_SERVER_SECRET}
KNOT_SERVER_DB_PATH: "/app/knotserver.db"
KNOT_REPO_SCAN_PATH: "/home/git/repositories"
+
KNOT_SERVER_INTERNAL_LISTEN_ADDR: "localhost:5444"
volumes:
- "./keys:/etc/ssh/keys"
- "./repositories:/home/git/repositories"
- "./server:/app"
ports:
+
- "5555:5555"
- "2222:22"
+
restart: always
frontend:
image: caddy:2-alpine
command: >
···
depends_on:
- knot
ports:
-
- "443:443"
-
- "443:443/udp"
+
- "${KNOT_SERVER_PORT:-443}:443"
+
- "${KNOT_SERVER_PORT:-443}:443/udp"
volumes:
- caddy_data:/data
restart: always
-
volumes:
-
caddy_data:
+
profiles: ["caddy"]
+8
rootfs/etc/s6-overlay/scripts/keys-wrapper
···
+
#!/bin/sh
+
+
# Execute the knot keys command with proper shell context
+
exec /bin/sh -c '/usr/local/bin/knot keys \
+
-output authorized-keys \
+
-internal-api "http://${KNOT_SERVER_INTERNAL_LISTEN_ADDR:-localhost:5444}" \
+
-git-dir "${KNOT_REPO_SCAN_PATH:-/home/git/repositories}" \
+
-log-path "/tmp/knotguard.log"'
+1 -1
rootfs/etc/ssh/sshd_config.d/tangled_sshd.conf
···
PasswordAuthentication no
Match User git
-
AuthorizedKeysCommand /usr/local/bin/knot keys -o authorized-keys
+
AuthorizedKeysCommand /etc/s6-overlay/scripts/keys-wrapper
AuthorizedKeysCommandUser nobody