From ed62c4ccf06c2c85d871a6334e3e0d82c6e4257a Mon Sep 17 00:00:00 2001 From: delusionalai Date: Sun, 15 Nov 2026 13:54:36 +0000 Subject: The host, built around the access control executable git-host is now the single home of the git repo configuration. The Dockerfile grew a build stage that installs git-authz from its own repository (the access-control / git-host-c project) via `make install`, so the image carries the executable, its example policy and the pre-receive hook symlink, all placed by the program's own installer rather than copied by hand. The server configuration is the git-authz-aware set that used to live beside the program: the entrypoint sets core.hooksPath and refuses to serve on a policy the hook cannot use, sshd carries PermitUserEnvironment and ForceCommand so a key's identity survives to the hook, create-repo prints the policy line to add, and git-host-key manages keys that name their user. cgitrc keeps the corrected ordering (repo-scoped settings above scan-path). --- Dockerfile | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 11 deletions(-) (limited to 'Dockerfile') diff --git a/Dockerfile b/Dockerfile index d92efca..b604336 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,31 @@ +# The git host: cgit, sshd and lighttpd around the access control executable. +# +# podman build -t git-host . +# +# Two stages: the runtime image carries no compiler, and copies what the +# program's own `make install` staged, so image paths cannot drift from build +# paths. The access control program is not configured here - it is built from +# its own repository (git-host-c / access-control) and installed by its own +# installer; this file only assembles the server that runs it. +# +# The build stage is Alpine so the binary is musl-linked like the rest of the +# image. A glibc binary reports "no such file" for a file that is plainly there. + + +FROM alpine:3.22.4 AS build +ARG GIT_HOST_C_URI=https://git.jnsn.dev/cgit/access-control.git +ARG GIT_HOST_C_REF=main +RUN apk add --no-cache build-base git +WORKDIR /src +RUN git clone --depth 1 --branch "${GIT_HOST_C_REF}" "${GIT_HOST_C_URI}" /src +# The suite runs against the musl build, which is the only place the two meet. +RUN make -j2 && make test && make install DESTDIR=/install + + FROM alpine:3.22.4 +# git-daemon is not a typo: it is the package that ships git-http-backend and +# git-shell. RUN apk add --no-cache \ cgit \ git \ @@ -11,7 +37,7 @@ RUN apk add --no-cache \ RUN addgroup -g 1000 -S git \ && adduser -u 1000 -S -D -G git -h /var/lib/git -s /usr/bin/git-shell git \ - && adduser git tty\ + && adduser git tty \ && passwd -u git \ && mkdir -p \ /etc/git-host/secrets \ @@ -24,20 +50,33 @@ RUN addgroup -g 1000 -S git \ /var/www/localhost/htdocs \ && chown -R git:git /var/lib/git -COPY entrypoint.sh /usr/local/bin/entrypoint.sh -COPY git-http-backend.cgi /usr/local/libexec/git-http-backend.cgi -COPY create-repo.sh /usr/local/bin/create-repo -COPY sshd_config /etc/ssh/sshd_config -COPY cgitrc /etc/cgitrc -COPY lighttpd.conf /etc/lighttpd/lighttpd.conf -COPY auth.conf /etc/lighttpd/auth.conf -COPY healthz /var/www/localhost/htdocs/healthz +# The access control executable, its example policy and the pre-receive hook +# symlink, all placed by the program's own installer. + +COPY --from=build /install/ / + +COPY entrypoint.sh /usr/local/bin/entrypoint.sh +COPY git-host-key /usr/local/bin/git-host-key +COPY create-repo.sh /usr/local/bin/create-repo +COPY git-http-backend.cgi /usr/local/libexec/git-http-backend.cgi +COPY sshd_config /etc/ssh/sshd_config +COPY cgitrc /etc/cgitrc +COPY lighttpd.conf /etc/lighttpd/lighttpd.conf +COPY auth.conf /etc/lighttpd/auth.conf +COPY healthz /var/www/localhost/htdocs/healthz -RUN chmod 0755 /usr/local/bin/entrypoint.sh /usr/local/libexec/git-http-backend.cgi /usr/local/bin/create-repo \ +RUN chmod 0755 \ + /usr/local/bin/entrypoint.sh \ + /usr/local/bin/git-host-key \ + /usr/local/bin/create-repo \ + /usr/local/libexec/git-http-backend.cgi \ + && chmod 0644 /etc/git-host/authz.conf \ && chown git:git /var/lib/git /run/lighttpd /var/tmp/lighttpd /var/www/localhost/htdocs \ && chmod 0755 /run/git-host /run/git-host/secrets \ + && git config --file /etc/gitconfig core.hooksPath /usr/local/share/git-host/hooks \ && grep -q "^git:" /etc/passwd \ - && lighttpd -tt -f /etc/lighttpd/lighttpd.conf + && lighttpd -tt -f /etc/lighttpd/lighttpd.conf \ + && /usr/local/bin/git-authz validate EXPOSE 8080 2222 VOLUME ["/var/lib/git"] -- cgit v1.2.3