Community maintained Docker config for the spindle server

all: init

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

anirudh.fi 9533f374

verified
Changed files
+114
rootfs
etc
s6-overlay
s6-rc.d
create-sshd-host-keys
knotserver
dependencies.d
run
sshd
user
contents.d
scripts
ssh
sshd_config.d
+37
Dockerfile
···
+
FROM docker.io/golang:1.24-alpine3.21 AS build
+
+
ENV CGO_ENABLED=1
+
WORKDIR /usr/src/app
+
COPY go.mod go.sum ./
+
+
RUN apk add --no-cache gcc musl-dev
+
RUN go mod download
+
+
COPY . .
+
RUN go build -v \
+
-o /usr/local/bin/knot \
+
-ldflags='-s -w -extldflags "-static"' \
+
./cmd/knot
+
+
FROM docker.io/alpine:3.21
+
+
LABEL org.opencontainers.image.title=Tangled
+
LABEL org.opencontainers.image.description="Tangled is a decentralized and open code collaboration platform, built on atproto."
+
LABEL org.opencontainers.image.vendor=Tangled.sh
+
LABEL org.opencontainers.image.licenses=MIT
+
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 && \
+
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 && \
+
mkdir /app && mkdir /home/git/repositories
+
+
COPY --from=build /usr/local/bin/knot /usr/local/bin
+
COPY docker/rootfs/ .
+
+
EXPOSE 22
+
EXPOSE 5555
+
+
ENTRYPOINT ["/bin/sh", "-c", "chown git:git /app && chown git:git /home/git/repositories && /init"]
+33
docker-compose.yml
···
+
services:
+
knot:
+
build:
+
context: ..
+
dockerfile: docker/Dockerfile
+
environment:
+
KNOT_SERVER_HOSTNAME: ${KNOT_SERVER_HOSTNAME}
+
KNOT_SERVER_SECRET: ${KNOT_SERVER_SECRET}
+
KNOT_SERVER_DB_PATH: "/app/knotserver.db"
+
KNOT_REPO_SCAN_PATH: "/home/git/repositories"
+
volumes:
+
- "./keys:/etc/ssh/keys"
+
- "./repositories:/home/git/repositories"
+
- "./server:/app"
+
ports:
+
- "2222:22"
+
frontend:
+
image: caddy:2-alpine
+
command: >
+
caddy
+
reverse-proxy
+
--from ${KNOT_SERVER_HOSTNAME}
+
--to knot:5555
+
depends_on:
+
- knot
+
ports:
+
- "443:443"
+
- "443:443/udp"
+
volumes:
+
- caddy_data:/data
+
restart: always
+
volumes:
+
caddy_data:
+4
readme.md
···
+
# knot-docker
+
+
This is a community maintained Docker setup for hosting your own knot
+
server.
+1
rootfs/etc/s6-overlay/s6-rc.d/create-sshd-host-keys/type
···
+
oneshot
+1
rootfs/etc/s6-overlay/s6-rc.d/create-sshd-host-keys/up
···
+
/etc/s6-overlay/scripts/create-sshd-host-keys
rootfs/etc/s6-overlay/s6-rc.d/knotserver/dependencies.d/base

This is a binary file and will not be displayed.

+3
rootfs/etc/s6-overlay/s6-rc.d/knotserver/run
···
+
#!/command/with-contenv ash
+
+
exec s6-setuidgid git /usr/local/bin/knot server
+1
rootfs/etc/s6-overlay/s6-rc.d/knotserver/type
···
+
longrun
rootfs/etc/s6-overlay/s6-rc.d/sshd/dependencies.d/base

This is a binary file and will not be displayed.

rootfs/etc/s6-overlay/s6-rc.d/sshd/dependencies.d/create-sshd-host-keys

This is a binary file and will not be displayed.

+3
rootfs/etc/s6-overlay/s6-rc.d/sshd/run
···
+
#!/usr/bin/execlineb -P
+
+
/usr/sbin/sshd -e -D
+1
rootfs/etc/s6-overlay/s6-rc.d/sshd/type
···
+
longrun
rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/knotserver

This is a binary file and will not be displayed.

rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/sshd

This is a binary file and will not be displayed.

+21
rootfs/etc/s6-overlay/scripts/create-sshd-host-keys
···
+
#!/usr/bin/execlineb -P
+
+
foreground {
+
if -n { test -d /etc/ssh/keys }
+
mkdir /etc/ssh/keys
+
}
+
+
foreground {
+
if -n { test -f /etc/ssh/keys/ssh_host_rsa_key }
+
ssh-keygen -t rsa -f /etc/ssh/keys/ssh_host_rsa_key -q -N ""
+
}
+
+
foreground {
+
if -n { test -f /etc/ssh/keys/ssh_host_ecdsa_key }
+
ssh-keygen -t rsa -f /etc/ssh/keys/ssh_host_ecdsa_key -q -N ""
+
}
+
+
foreground {
+
if -n { test -f /etc/ssh/keys/ssh_host_ed25519_key }
+
ssh-keygen -t rsa -f /etc/ssh/keys/ssh_host_ed25519_key -q -N ""
+
}
+9
rootfs/etc/ssh/sshd_config.d/tangled_sshd.conf
···
+
HostKey /etc/ssh/keys/ssh_host_rsa_key
+
HostKey /etc/ssh/keys/ssh_host_ecdsa_key
+
HostKey /etc/ssh/keys/ssh_host_ed25519_key
+
+
PasswordAuthentication no
+
+
Match User git
+
AuthorizedKeysCommand /usr/local/bin/knot keys -o authorized-keys
+
AuthorizedKeysCommandUser nobody