aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2026-07-05 14:38:46 +0530
committerAkshay Nair <phenax5@gmail.com>2026-07-05 16:15:17 +0530
commitd2fd01c0181fd557a1750d8c36fbe1394431766c (patch)
tree137f06d079b00960c28aecaf84f53cd159a0fbcc
parenteca86870bf10c064a9f561249491f03c6e750a86 (diff)
downloadbacchus-remote-d2fd01c0181fd557a1750d8c36fbe1394431766c.tar.gz
bacchus-remote-d2fd01c0181fd557a1750d8c36fbe1394431766c.zip
Install cgit from source
-rw-r--r--cgit/Dockerfile41
-rw-r--r--cgit/cgitrc3
-rwxr-xr-xcgit/install-cgit.sh36
-rw-r--r--cgit/nginx/conf.d/default.conf9
-rw-r--r--docker-compose.yml9
-rw-r--r--justfile4
-rwxr-xr-xsetup.sh6
7 files changed, 75 insertions, 33 deletions
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 <joseluisq.net>"
-
-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 <version>"
+ 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;
diff --git a/docker-compose.yml b/docker-compose.yml
index 8f1eff2..ebfe640 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -7,6 +7,7 @@ services:
ports:
- '1234:1234'
environment:
+ # proxy
- VIRTUAL_PORT=1234
- VIRTUAL_HOST=send.ediblemonad.dev
- LETSENCRYPT_HOST=send.ediblemonad.dev
@@ -22,6 +23,10 @@ services:
- MAX_EXPIRE_SECONDS=2592000 # 30 days
- MAX_DOWNLOADS=100
- MAX_FILE_SIZE=536870912 # 512M
+ deploy:
+ resources:
+ limits:
+ cpus: '0.2'
volumes:
- ${SEND_UPLOADS_ROOT:-/uploads}:/uploads
depends_on:
@@ -35,10 +40,12 @@ services:
ports:
- 8080:80
environment:
+ # proxy
- VIRTUAL_PORT=80
- VIRTUAL_HOST=git.ediblemonad.dev
- LETSENCRYPT_HOST=git.ediblemonad.dev
- DHPARAM_GENERATION=false
+ # cgit
- USE_CUSTOM_CONFIG=true
deploy:
resources:
@@ -79,7 +86,7 @@ services:
- DEFAULT_EMAIL=ediblemonad@gmail.com
- NGINX_PROXY_CONTAINER=nginx-proxy
- NGINX_DOCKER_GEN_CONTAINER=nginx-proxy
- - ACME_CA_URI=https://acme-staging-v02.api.letsencrypt.org/directory
+ # - ACME_CA_URI=https://acme-staging-v02.api.letsencrypt.org/directory
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- proxy-certs:/etc/nginx/certs
diff --git a/justfile b/justfile
index 67528c2..312bf01 100644
--- a/justfile
+++ b/justfile
@@ -9,7 +9,7 @@ ssh *args:
shell: ssh
copy *args:
- rsync -ravh --delete --exclude '.git' -e "ssh -p $SSH_PORT" "$@"
+ rsync -ravh --delete --exclude '.git' --exclude 'tmp' -e "ssh -p $SSH_PORT" "$@"
df:
just ssh 'df -ah /'
@@ -17,8 +17,6 @@ df:
upload:
just copy . "${SSH_USER}@${SSH_HOST}:{{TARGET_DIR}}"
-restart-remote: (setup "start")
-
setup *args:
just ssh "{{TARGET_DIR}}/setup.sh" "$@"
diff --git a/setup.sh b/setup.sh
index efd3954..16240cd 100755
--- a/setup.sh
+++ b/setup.sh
@@ -13,7 +13,11 @@ services() { cd "$ROOT_DIR"; docker compose --profile services "$@"; }
core() { cd "$ROOT_DIR"; docker compose --profile core "$@"; }
# TODO: use --wait and add health checks
-start() { stop || true; services up -d "$@"; }
+start() {
+ stop || true; services up -d "$@"
+ core down nginx
+ core up nginx -d
+}
startfg() { stop || true; services up "$@"; }