From 19e7dc8932cf6cc8671b474ae258921480d9c608 Mon Sep 17 00:00:00 2001 From: Malfurious Date: Sat, 12 Aug 2023 21:40:04 -0400 Subject: gitolite: Make admin pubkey an optional input to Docker image Automating the build of this image will be awkward if we need a user-supplied input file each time. At best, it will probably lead to building out of per-instance configuration branches that store the file... The initial administrator pubkey is only really needed to include in the first image that is run at any given site, since a new install doesn't have a config/repository datastore yet. Once that is the case, the procedure in the Dockerfile to init the /var/lib/gitolite directory (now refactored to a shell script file) can be skipped, since that directory will be replaced by the previous container's volume. This is probably not the final form of this kind of build design change, but will work for now to get up and running easily with cychedelic. Signed-off-by: Malfurious --- docker/Dockerfile.gitolite | 12 +++--------- docker/gitolite_init.sh | 6 ++++++ 2 files changed, 9 insertions(+), 9 deletions(-) create mode 100755 docker/gitolite_init.sh diff --git a/docker/Dockerfile.gitolite b/docker/Dockerfile.gitolite index 66367b5..d2ca1ae 100644 --- a/docker/Dockerfile.gitolite +++ b/docker/Dockerfile.gitolite @@ -4,20 +4,14 @@ FROM archlinux -# Set this to the administrator's SSH public key file (username.pub) -ARG pubkey - # The gitolite package implies git, openssh, and creates the host user RUN pacman-key --init RUN pacman -Syu --needed --noconfirm gitolite # Initialize the gitolite datastore -COPY $pubkey / -RUN runuser -u gitolite -- gitolite setup -pk /$pubkey -RUN runuser -u gitolite -- chmod 755 /var/lib/gitolite -RUN runuser -u gitolite -- chmod -R 755 /var/lib/gitolite/repositories -RUN runuser -u gitolite -- ln -sf .gitolite/conf/.gitolite.rc /var/lib/gitolite -RUN runuser -u gitolite -- ln -sf .gitolite/conf/.gitconfig /var/lib/gitolite +COPY . /app +RUN if [ -f "/app/admin.pub" ]; \ + then runuser -u gitolite -- /app/gitolite_init.sh "/app/admin.pub"; fi VOLUME /var/lib/gitolite # sshd host keys are stored in a volume so that rebuilding/updating the diff --git a/docker/gitolite_init.sh b/docker/gitolite_init.sh new file mode 100755 index 0000000..bd70222 --- /dev/null +++ b/docker/gitolite_init.sh @@ -0,0 +1,6 @@ +#!/bin/sh +gitolite setup -pk "$1" +chmod 755 /var/lib/gitolite +chmod -R 755 /var/lib/gitolite/repositories +ln -sf .gitolite/conf/.gitolite.rc /var/lib/gitolite +ln -sf .gitolite/conf/.gitconfig /var/lib/gitolite -- cgit v1.2.3