From cb9c463d152c0607f2d0e2df2de043e404b7375d Mon Sep 17 00:00:00 2001 From: memdmp <memdmp@estrogen.zone> Date: Fri, 3 Jan 2025 03:51:16 +0100 Subject: fix: we use a containerfile in this household --- Containerfile | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 84 ----------------------------------------------------------- compose.yml | 2 +- 3 files changed, 85 insertions(+), 85 deletions(-) create mode 100644 Containerfile delete mode 100644 Dockerfile diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..4e88152 --- /dev/null +++ b/Containerfile @@ -0,0 +1,84 @@ +FROM docker.io/alpine:latest AS base + +WORKDIR /root + +# Funny lil packages +RUN apk upgrade --no-cache && \ + apk add --no-cache \ + git openssh \ + python3 py3-pygments \ + py3-markdown \ + libintl musl-libintl \ + zlib \ + caddy \ + cgit gitolite \ + openssl \ + dumb-init \ + fcgiwrap \ + sudo zsh openrc \ + libcap + +ADD image/prepare-container.sh /usr/local/bin/prepare-container.sh +ADD image/fcgiwrap-launcher /usr/local/bin/fcgiwrap-launcher +RUN chmod +x /usr/local/bin/prepare-container.sh /usr/local/bin/fcgiwrap-launcher + +# SSHD config : no password, no strict mode +# Moved by prepare-container.sh +ADD image/sshd_config /etc/sshd_config + +# CGIT Config +# Copied by prepare-container.sh +ADD image/cgitrc /etc/cgitrc.default + +# Caddy config +ADD image/Caddyfile /etc/caddy/Caddyfile + +# Remove SSH keyes, fresh keys will be generated at container startup by prepare-container.sh +RUN rm -rf /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_dsa_key + +# Gitolis / Gitolite +RUN adduser -D -g "" -s "/bin/ash" http +RUN addgroup git www-data && addgroup git http +RUN addgroup http www-data && addgroup http git +# We need a password set, otherwise pubkey auth doesn't work... why ?? /sbin/nologin doesn't work either +RUN echo "git:$(openssl rand -hex 4096)" | chpasswd + +# Caddy needs CAP_NET_BIND_SERVICE +RUN setcap CAP_NET_BIND_SERVICE=+eip /usr/sbin/caddy + +RUN ln -s /var/lib/git/cgitrc /etc/cgitrc + +# SSH Keys, Config +VOLUME ["/etc/ssh"] +# Git Directories +VOLUME ["/var/lib/git"] + +# CGit +EXPOSE 80 +# SSH +EXPOSE 22 + +ENTRYPOINT ["/usr/bin/dumb-init", "--"] +CMD ["sh", "-c", "/usr/local/bin/prepare-container.sh && sh -c 'sleep 1 && chgrp www-data /run/fcgiwrap/fcgiwrap.sock && chmod g+w /run/fcgiwrap/fcgiwrap.sock && exec sudo -u http /usr/sbin/caddy run --config /etc/caddy/Caddyfile --adapter caddyfile' & /usr/local/bin/fcgiwrap-launcher"] + +FROM base AS with-fmt +RUN apk add --no-cache py3-markdown py3-docutils groff +RUN echo -ne 'about-filter=/usr/lib/cgit/filters/about-formatting.sh\n' >> /etc/cgitrc.default + +FROM with-fmt AS with-highlighting +RUN apk add --no-cache highlight +ADD image/syntax-highlighting.sh /usr/lib/cgit/filters/syntax-highlighting-uwu.sh +RUN chmod +x /usr/lib/cgit/filters/syntax-highlighting-uwu.sh +RUN echo -ne 'source-filter=/usr/lib/cgit/filters/syntax-highlighting-uwu.sh\n' >> /etc/cgitrc.default + +FROM with-highlighting AS full +# with nice userland aswell +RUN apk add --no-cache curl zsh-fast-syntax-highlighting +RUN sed -i 's|/bin/ash|/bin/zsh|g' /etc/passwd +RUN (git clone https://git.estrogen.zone/zuwu.git/ /tmp/zuwu || git clone https://github.com/dmpmem/zuwu.git /tmp/zuwu) && \ + cd /tmp/zuwu && \ + ./install.zsh && \ + /usr/local/share/zsh/plugins/zuwu/setup.zsh && \ + sudo -u git /usr/local/share/zsh/plugins/zuwu/setup.zsh && \ + cd ~ && \ + rm -rf /tmp/zuwu diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 7e0d7b0..0000000 --- a/Dockerfile +++ /dev/null @@ -1,84 +0,0 @@ -FROM docker.io/alpine:latest AS base - -WORKDIR /root - -# Packages we'll keep -RUN apk upgrade --no-cache && \ - apk add --no-cache \ - git openssh \ - python3 py3-pygments \ - py3-markdown \ - libintl musl-libintl \ - zlib \ - caddy \ - cgit gitolite \ - openssl \ - dumb-init \ - fcgiwrap \ - sudo zsh openrc \ - libcap - -ADD image/prepare-container.sh /usr/local/bin/prepare-container.sh -ADD image/fcgiwrap-launcher /usr/local/bin/fcgiwrap-launcher -RUN chmod +x /usr/local/bin/prepare-container.sh /usr/local/bin/fcgiwrap-launcher - -# SSHD config : no password, no strict mode -# Moved by prepare-container.sh -ADD image/sshd_config /etc/sshd_config - -# CGIT Config -# Copied by prepare-container.sh -ADD image/cgitrc /etc/cgitrc.default - -# Caddy config -ADD image/Caddyfile /etc/caddy/Caddyfile - -# Remove SSH keyes, fresh keys will be generated at container startup by prepare-container.sh -RUN rm -rf /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_dsa_key - -# Gitolis / Gitolite -RUN adduser -D -g "" -s "/bin/ash" http -RUN addgroup git www-data && addgroup git http -RUN addgroup http www-data && addgroup http git -# We need a password set, otherwise pubkey auth doesn't work... why ?? /sbin/nologin doesn't work either -RUN echo "git:$(openssl rand -hex 4096)" | chpasswd - -# Caddy needs CAP_NET_BIND_SERVICE -RUN setcap CAP_NET_BIND_SERVICE=+eip /usr/sbin/caddy - -RUN ln -s /var/lib/git/cgitrc /etc/cgitrc - -# SSH Keys, Config -VOLUME ["/etc/ssh"] -# Git Directories -VOLUME ["/var/lib/git"] - -# CGit -EXPOSE 80 -# SSH -EXPOSE 22 - -ENTRYPOINT ["/usr/bin/dumb-init", "--"] -CMD ["sh", "-c", "/usr/local/bin/prepare-container.sh && sh -c 'sleep 1 && chgrp www-data /run/fcgiwrap/fcgiwrap.sock && chmod g+w /run/fcgiwrap/fcgiwrap.sock && exec sudo -u http /usr/sbin/caddy run --config /etc/caddy/Caddyfile --adapter caddyfile' & /usr/local/bin/fcgiwrap-launcher"] - -FROM base AS with-fmt -RUN apk add --no-cache py3-markdown py3-docutils groff -RUN echo -ne 'about-filter=/usr/lib/cgit/filters/about-formatting.sh\n' >> /etc/cgitrc.default - -FROM with-fmt AS with-highlighting -RUN apk add --no-cache highlight -ADD image/syntax-highlighting.sh /usr/lib/cgit/filters/syntax-highlighting-uwu.sh -RUN chmod +x /usr/lib/cgit/filters/syntax-highlighting-uwu.sh -RUN echo -ne 'source-filter=/usr/lib/cgit/filters/syntax-highlighting-uwu.sh\n' >> /etc/cgitrc.default - -FROM with-highlighting AS full -# with nice userland aswell -RUN apk add --no-cache curl zsh-fast-syntax-highlighting -RUN sed -i 's|/bin/ash|/bin/zsh|g' /etc/passwd -RUN (git clone https://git.estrogen.zone/zuwu.git/ /tmp/zuwu || git clone https://github.com/dmpmem/zuwu.git /tmp/zuwu) && \ - cd /tmp/zuwu && \ - ./install.zsh && \ - /usr/local/share/zsh/plugins/zuwu/setup.zsh && \ - sudo -u git /usr/local/share/zsh/plugins/zuwu/setup.zsh && \ - cd ~ && \ - rm -rf /tmp/zuwu diff --git a/compose.yml b/compose.yml index a60b686..d5996f5 100644 --- a/compose.yml +++ b/compose.yml @@ -3,7 +3,7 @@ services: image: docker.io/memdmp/cgit:local-build build: context: . - dockerfile: ./Dockerfile + dockerfile: ./Containerfile volumes: - cgit_ssh:/etc/ssh:rw - ./cgit/repos:/var/lib/git:rw -- cgit v1.2.3