summaryrefslogtreecommitdiffstats
path: root/container/Dockerfile
diff options
context:
space:
mode:
authordev <dev@example>2026-11-14 01:05:08 +0000
committerdev <dev@example>2026-11-14 01:05:08 +0000
commit312ddd4936f09ae27a180ca495cacf2c06faf33e (patch)
tree2fa46ab568ad55f7e8fb844c3447b1d296b2e340 /container/Dockerfile
parente737f3d560de2b8172e6dd83901bc1359283303c (diff)
downloadaccess-control-312ddd4936f09ae27a180ca495cacf2c06faf33e.tar.gz
access-control-312ddd4936f09ae27a180ca495cacf2c06faf33e.zip
Comments: cut to what the code cannot say
The comments had grown into essays. A file header explaining why the file exists, then a paragraph above each function restating what the next eight lines do, then a paragraph above that one explaining why that matters. The reader gets no further than the first paragraph, and the second is the one that goes stale: it describes code that has since changed, and nothing fails when it does. Cut by about half. What is left is the three things a comment can do that code cannot: say why the constraint exists (no regex because a hook must not depend on what might be missing at 3am), say what is not obvious from the shape (a bare ref name is a branch, never a tag; the seventh field of /etc/passwd is the shell), and say where it hurts (the NULL in an execvp array, the mode and owner that have to survive an atomic rewrite, the child that must not keep the hook's stdin). Block comments became // lines, which is also what the other C trees here use, and the file headers went to two or three lines. Section banners stayed: they are navigation, not prose. Behaviour is unchanged and the suites prove it: 171 direct checks, 162 behavioural, clean under -Werror and under ASan/UBSan.
Diffstat (limited to 'container/Dockerfile')
-rw-r--r--container/Dockerfile37
1 files changed, 13 insertions, 24 deletions
diff --git a/container/Dockerfile b/container/Dockerfile
index 1828748..ac0d898 100644
--- a/container/Dockerfile
+++ b/container/Dockerfile
@@ -1,22 +1,11 @@
-# git-host on top of the C program.
-#
-# podman build -t git-host-c .
-#
-# Two stages, because the runtime image has no business carrying a compiler.
-# The build stage compiles, runs the test suite, and installs into a staging
-# root; the runtime stage copies that staging root wholesale, so the paths in
-# the image are the paths `make install` produces - including the hook symlink
-# and its relative target - rather than a second list of destinations kept here,
-# which is how an image and a build start to disagree.
-#
-# The build stage is Alpine so that git-authz is musl-linked like everything
-# else in the runtime image. A glibc binary built on the machine doing the
-# building would not run in there, and would announce itself as "no such file"
-# for a file that is plainly present.
+# podman build -t git-host-c -f container/Dockerfile .
#
-# The build context is the program's directory, with this file in container/:
+# Two stages: the runtime image carries no compiler, and copies what `make
+# install` staged, so image paths cannot drift from build paths.
#
-# podman build -t git-host-c -f container/Dockerfile .
+# 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
RUN apk add --no-cache build-base
@@ -26,9 +15,8 @@ COPY src ./src
COPY cmd ./cmd
COPY test ./test
COPY build ./build
-# The suite runs in the image it ships in, against the musl build: that is the
-# only place the two are guaranteed to meet, and an image built from a tree
-# whose tests fail should not exist.
+# The suite runs against the musl build, which is the only place the two meet.
+
RUN make -j2 && make test && make install DESTDIR=/install
@@ -60,16 +48,17 @@ RUN addgroup -g 1000 -S git \
/var/www/localhost/htdocs \
&& chown -R git:git /var/lib/git
-# The binary, the hook symlink beside it, and the example policy, all placed by
-# the program's own installer.
+# Placed by the program's own installer.
+
COPY --from=build /install/ /
COPY container/create-repo /usr/local/bin/create-repo
COPY container/git-host-key /usr/local/bin/git-host-key
COPY container/entrypoint.sh /usr/local/bin/entrypoint.sh
-# lighttpd's mod_cgi dispatches by extension, so /git needs a *.cgi door. It
-# only execs the stock backend, leaving REMOTE_USER for the hooks to find.
+# mod_cgi dispatches by extension, so /git needs a *.cgi door onto the stock
+# backend. It must not touch the environment: REMOTE_USER is the identity.
+
COPY container/git-http-backend.cgi /usr/local/libexec/git-http-backend.cgi
COPY container/sshd_config /etc/ssh/sshd_config