From d2fd01c0181fd557a1750d8c36fbe1394431766c Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sun, 5 Jul 2026 14:38:46 +0530 Subject: Install cgit from source --- cgit/Dockerfile | 41 ++++++++++++++++------------------------- cgit/cgitrc | 3 ++- cgit/install-cgit.sh | 36 ++++++++++++++++++++++++++++++++++++ cgit/nginx/conf.d/default.conf | 9 +++++++-- 4 files changed, 61 insertions(+), 28 deletions(-) create mode 100755 cgit/install-cgit.sh (limited to 'cgit') diff --git a/cgit/Dockerfile b/cgit/Dockerfile index 86b3005..2988d2e 100644 --- a/cgit/Dockerfile +++ b/cgit/Dockerfile @@ -1,22 +1,9 @@ -FROM nginx:1.28.1-alpine3.23 - -ARG VERSION=0.0.0 -ENV VERSION=${VERSION} +FROM nginx:1.31.2-alpine3.23 RUN addgroup -S git -g 1001 && adduser -S -G git -u 1001 -D git -# CGit -ARG CGIT_VERSION=1.2.3-r5 -ENV CGIT_VERSION=${CGIT_VERSION} - -LABEL version="${VERSION}" \ - description="The hyperfast web frontend for Git repositories on top of Alpine and Nginx." \ - maintainer="Jose Quintana " - -RUN set -eux \ - && apk add --no-cache \ +RUN apk add --no-cache \ ca-certificates \ - cgit=${CGIT_VERSION} \ fcgiwrap \ git \ lua5.3-libs \ @@ -27,12 +14,24 @@ RUN set -eux \ python3 \ spawn-fcgi \ tzdata \ + && true + +# Cgit build deps +RUN apk add --no-cache \ + make \ + gcc \ + musl-dev \ xz \ zlib \ - && rm -rf /var/cache/apk/* \ - && rm -rf /tmp/* \ + zlib-dev \ + openssl-dev \ && true +COPY install-cgit.sh / +RUN /install-cgit.sh "1.3.1" + +RUN rm -rf /var/cache/apk/* && rm -rf /tmp/* + COPY docker-entrypoint.sh / RUN chmod +x /docker-entrypoint.sh COPY nginx/ /etc/nginx @@ -57,11 +56,3 @@ EXPOSE 80 STOPSIGNAL SIGQUIT CMD [ "nginx", "-g", "daemon off;" ] - -# Metadata -LABEL org.opencontainers.image.vendor="Jose Quintana" \ - org.opencontainers.image.url="https://github.com/joseluisq/alpine-cgit" \ - org.opencontainers.image.title="cgit" \ - org.opencontainers.image.description="The hyperfast web frontend for Git repositories on top of Alpine and Nginx." \ - org.opencontainers.image.version="${VERSION}" \ - org.opencontainers.image.documentation="https://github.com/joseluisq/alpine-cgit" diff --git a/cgit/cgitrc b/cgit/cgitrc index 468e859..4e2521a 100644 --- a/cgit/cgitrc +++ b/cgit/cgitrc @@ -67,7 +67,7 @@ cache-static-ttl=30 enable-index-links=1 enable-index-owner=0 enable-remote-branches=1 -enable-log-filecount=1 +enable-log-filecount=0 enable-log-linecount=0 # This shit is slow enable-tree-linenumbers=1 enable-git-config=1 @@ -83,6 +83,7 @@ max-repo-count=50 max-blob-size=512 max-commit-count=20 max-message-length=72 +renamelimit=5 # side-by-side-diffs=1 diff --git a/cgit/install-cgit.sh b/cgit/install-cgit.sh new file mode 100755 index 0000000..58b9e1d --- /dev/null +++ b/cgit/install-cgit.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env sh + +set -eu + +if [ $# -lt 1 ] || [ -z "$1" ]; then + echo "Usage: install-cgit.sh " + exit 1 +fi + +VERSION=$1 + +CLONE_DIR=${CLONE_DIR:-"/tmp/.cgit-install-dir"} +mkdir -p "$CLONE_DIR" +cd "$CLONE_DIR" + +if ! [ -d "cgit-${VERSION}" ]; then + wget -O cgit.tar.xz "https://git.zx2c4.com/cgit/snapshot/cgit-${VERSION}.tar.xz" + unxz cgit.tar.xz + tar xf cgit.tar + cd "cgit-${VERSION}" + make get-git + echo "NO_REGEX=NeedsStartEnd" >> git/config.mak + echo "NO_GETTEXT=1" >> git/config.mak +else + cd "cgit-${VERSION}" +fi + +make +make prefix=/usr \ + CGIT_SCRIPT_PATH=/usr/share/webapps/cgit-script \ + CGIT_DATA_PATH=/usr/share/webapps/cgit \ + install + +cd "$CLONE_DIR" +rm -rf cgit.tar cgit.tar.xz + diff --git a/cgit/nginx/conf.d/default.conf b/cgit/nginx/conf.d/default.conf index 7254ffa..73db0db 100644 --- a/cgit/nginx/conf.d/default.conf +++ b/cgit/nginx/conf.d/default.conf @@ -3,18 +3,23 @@ server { server_name localhost; root /usr/share/webapps/cgit; - location ~* ^.+(ediblemonad.+|favicon.ico|robots.txt) { + location ~* ^/(ediblemonad/.+|favicon.ico|robots.txt) { root /usr/share/webapps/cgit; expires 30d; } + location ~* ^.+/plain/.+ { + try_files $uri @cgit; + expires 15d; + } + location / { try_files $uri @cgit; } location @cgit { include /etc/nginx/fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root/cgit.cgi; + fastcgi_param SCRIPT_FILENAME /usr/share/webapps/cgit-script/cgit.cgi; fastcgi_param PATH_INFO $uri; fastcgi_param QUERY_STRING $args; fastcgi_param HTTP_HOST $server_name; -- cgit v1.3.1