From a27bd8f0125f0c19d1059c9e0865f4971ca9f991 Mon Sep 17 00:00:00 2001 From: hanna Date: Wed, 4 Jun 2025 13:51:11 -0400 Subject: [PATCH] all: update to clone from core repo --- Dockerfile | 75 +++++++++----------- rootfs/etc/s6-overlay/s6-rc.d/knotserver/run | 2 +- rootfs/etc/s6-overlay/scripts/keys-wrapper | 6 +- 3 files changed, 36 insertions(+), 47 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6ae3516..f3ad9f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,44 +1,33 @@ -FROM docker.io/golang:1.24-alpine3.21 AS build +from golang:1.24-alpine as builder +env KNOT_REPO_SCAN_PATH=/home/git/repositories +env CGO_ENABLED=1 + +workdir /app +run apk add git gcc musl-dev +run git clone https://tangled.sh/@tangled.sh/core . +run go build -o /usr/bin/knot -ldflags '-s -w -extldflags "-static"' ./cmd/knot + +from alpine:edge +expose 5555 +expose 22 + +label org.opencontainers.image.title='knot' +label org.opencontainers.image.description='data server for tangled' +label org.opencontainers.image.source='https://tangled.sh/@tangled.sh/knot-docker' +label org.opencontainers.image.url='https://tangled.sh' +label org.opencontainers.image.vendor='tangled.sh' +label org.opencontainers.image.licenses='MIT' + +copy rootfs . +run chmod -R 755 /etc/s6-overlay +run apk add shadow s6-overlay execline openssl openssh git curl +run useradd -s /bin/nologin -d /home/git git && openssl rand -hex 16 | passwd --stdin git +run mkdir -p /home/git/repositories && chown -R git:git /home/git/repositories +copy --from=builder /usr/bin/knot /usr/bin +run mkdir /app && chown -R git:git /app + +healthcheck --interval=60s --timeout=30s --start-period=5s --retries=3 \ + cmd curl -f http://localhost:5555 || exit 1 + +entrypoint ["/init"] -ENV CGO_ENABLED=1 -ENV KNOT_REPO_SCAN_PATH=/home/git/repositories -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 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 && \ - mkdir /app && mkdir /home/git/repositories - -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 - -HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ - CMD curl -f http://localhost:5555/ || exit 1 - -ENTRYPOINT ["/init"] \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/knotserver/run b/rootfs/etc/s6-overlay/s6-rc.d/knotserver/run index 3d5ecf1..a210fc4 100755 --- a/rootfs/etc/s6-overlay/s6-rc.d/knotserver/run +++ b/rootfs/etc/s6-overlay/s6-rc.d/knotserver/run @@ -1,3 +1,3 @@ #!/command/with-contenv ash -exec s6-setuidgid git /usr/local/bin/knot server +exec s6-setuidgid git /usr/bin/knot server diff --git a/rootfs/etc/s6-overlay/scripts/keys-wrapper b/rootfs/etc/s6-overlay/scripts/keys-wrapper index 67c1a66..e35ffc3 100644 --- a/rootfs/etc/s6-overlay/scripts/keys-wrapper +++ b/rootfs/etc/s6-overlay/scripts/keys-wrapper @@ -1,8 +1,8 @@ #!/bin/sh # Execute the knot keys command with proper shell context -exec /bin/sh -c '/usr/local/bin/knot keys \ - -output authorized-keys \ +exec /bin/sh -c '/usr/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"' \ No newline at end of file + -log-path "/tmp/knotguard.log"' + -- 2.51.2