docker: fix config #198

closed
opened by knotbin.com targeting master from [deleted fork]: fix-docker

(i be traumatized) fixes knotguard options, along with some more config improvements and fixes in docker compose and dockerfile

Changed files
+11 -8
docker
rootfs
etc
ssh
sshd_config.d
guard
keyfetch
+2 -1
docker/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 ./
···
EXPOSE 22
EXPOSE 5555
-
ENTRYPOINT ["/bin/sh", "-c", "chown git:git /app && chown git:git /home/git/repositories && /init"]
+
ENTRYPOINT ["/bin/sh", "-c", "chown git:git /app && chown -R git:git \"$KNOT_REPO_SCAN_PATH\" && /init"]
+6 -4
docker/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"]
+1 -1
docker/rootfs/etc/ssh/sshd_config.d/tangled_sshd.conf
···
PasswordAuthentication no
Match User git
-
AuthorizedKeysCommand /usr/local/bin/knot keys -o authorized-keys
+
AuthorizedKeysCommand /usr/local/bin/knot keys -output authorized-keys -internal-api http://$(echo ${KNOT_SERVER_INTERNAL_LISTEN_ADDR:-localhost:5444}) -git-dir ${KNOT_REPO_SCAN_PATH:-/home/git/repositories} -log-path /tmp/knotguard.log
AuthorizedKeysCommandUser nobody
+1 -1
guard/guard.go
···
&cli.StringFlag{
Name: "internal-api",
Usage: "internal API endpoint",
-
Value: "http://localhost:5444",
+
Value: "http://localhost:5555",
},
},
}
+1 -1
keyfetch/keyfetch.go
···
&cli.StringFlag{
Name: "internal-api",
Usage: "internal API endpoint",
-
Value: "http://localhost:5444",
+
Value: "http://127.0.0.1:5444",
},
&cli.StringFlag{
Name: "git-dir",