DEPRECATED: Use the community maintained https://tangled.sh/@tangled.sh/knot-docker instead

initial commit

+24
Dockerfile
···
+
FROM alpine AS build
+
RUN apk add --update go git
+
RUN git clone https://tangled.sh/@tangled.sh/core /src
+
WORKDIR /src
+
ENV CGO_ENABLED=1
+
RUN cd cmd/knotserver && go build
+
RUN cd cmd/keyfetch && go build
+
RUN cd cmd/repoguard && go build
+
FROM alpine
+
RUN apk add --update git openssh-server su-exec
+
RUN addgroup -g 1000 git && \
+
adduser -D -u 1000 -G git -h /home/git git && \
+
mkdir -p /home/git && \
+
chown -R git:git /home/git
+
COPY --from=build /src/cmd/knotserver/knotserver /usr/bin/knotserver
+
COPY --from=build /src/cmd/keyfetch/keyfetch /usr/bin/keyfetch
+
COPY --from=build /src/cmd/repoguard/repoguard /usr/bin/repoguard
+
COPY keyfetch_sshd_config /tmp/keyfetch
+
RUN cat /tmp/keyfetch >> /etc/ssh/sshd_config && rm /tmp/keyfetch
+
COPY ssh_host_ed25519_key /etc/ssh
+
COPY ssh_host_ed25519_key.pub /etc/ssh
+
RUN chmod 600 /etc/ssh/ssh_host_ed25519_key
+
RUN chmod 644 /etc/ssh/ssh_host_ed25519_key.pub
+
CMD ["/bin/sh", "-c", "chown -R git:git /home/git && /usr/sbin/sshd && su-exec git knotserver"]
+10
README.md
···
+
Quick instructions:
+
- run `gen-key.sh` to generate an ssh host key
+
- set the server name in both `conf/Caddyfile` and in `knot.env.template`
+
- register a knot on tangled.sh and put the secret key in `knot.env.template`
+
- spin up the container and test that it works
+
+
Buyer beware, this is a very new and untested setup for alpha software,
+
so don't commit any overly precious code to this.
+
+
-- Anil Madhavapeddy <anil@recoil.org>
+3
conf/Caddyfile
···
+
git.recoil.org {
+
reverse_proxy knotserver:5555
+
}
+30
docker-compose.yml
···
+
services:
+
frontend:
+
image: caddy:2-alpine
+
depends_on:
+
- knotserver
+
ports:
+
- "443:443"
+
- "443:443/udp"
+
- "80:80"
+
volumes:
+
- caddy_data:/data
+
- ./conf:/etc/caddy
+
knotserver:
+
environment:
+
- KNOT_REPO_SCAN_PATH=/home/git
+
- KNOT_REPO_MAIN_BRANCH=main
+
- KNOT_SERVER_DB_PATH=/home/git/knotserver.db
+
- APPVIEW_ENDPOINT=https://tangled.sh
+
- KNOT_SERVER_INTERNAL_LISTEN_ADDR=0.0.0.0:5444
+
- KNOT_SERVER_LISTEN_ADDR=0.0.0.0:5555
+
env_file: knot.env
+
build:
+
dockerfile: Dockerfile
+
volumes:
+
- knot_data:/home/git
+
ports:
+
- "2222:22"
+
volumes:
+
caddy_data:
+
knot_data:
+3
gen-key.sh
···
+
#!/bin/sh
+
+
ssh-keygen -t ed25519 -f ./ssh_host_ed25519_key -N ""
+3
keyfetch_sshd_config
···
+
Match User git
+
AuthorizedKeysCommand /usr/bin/keyfetch -repoguard-path /usr/bin/repoguard
+
AuthorizedKeysCommandUser nobody
+2
knot.env.template
···
+
KNOT_SERVER_HOSTNAME=<your hostname>
+
KNOT_SERVER_SECRET=<secret string from the tangled.sh ui>