summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLambda <lambda@disroot.org>2025-12-10 15:19:24 -0500
committerLambda <lambda@disroot.org>2025-12-10 15:19:24 -0500
commit0c79ff01fe7eb5abf369e4c14edf8eeadb692c3b (patch)
tree36aed08de5add804cacb8286ef0768381ffa5b4a
downloadcgit-docker-0c79ff01fe7eb5abf369e4c14edf8eeadb692c3b.tar.gz
cgit-docker-0c79ff01fe7eb5abf369e4c14edf8eeadb692c3b.tar.bz2
cgit-docker-0c79ff01fe7eb5abf369e4c14edf8eeadb692c3b.zip
Initial commit
-rw-r--r--Dockerfile31
-rw-r--r--LICENSE21
-rw-r--r--cgit.conf7
-rw-r--r--etc/cgitrc57
-rw-r--r--etc/httpd/httpd.conf45
-rw-r--r--opt/highlight.sh23
6 files changed, 184 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..3190d9f
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,31 @@
+FROM rockylinux:9
+LABEL MAINTAINER="Lambda <lambda@disroot.org>"
+
+# Update everything; install dependencies.
+RUN dnf -y update && dnf -y upgrade \
+ && dnf install -y git gcc make openssl-devel zlib-devel zip \
+ highlight httpd \
+ && dnf clean all
+
+# Install cgit.
+RUN git clone https://git.zx2c4.com/cgit
+ADD cgit.conf cgit
+RUN cd cgit \
+ && git submodule init \
+ && git submodule update \
+ && make NO_LUA=1 \
+ && make install \
+ && cd .. \
+ && rm -rf cgit
+
+# Configure.
+ADD etc/cgitrc /etc/cgitrc
+ADD etc/httpd/httpd.conf /etc/httpd/conf/httpd.conf
+
+# Add custom syntax highlighting.
+COPY opt/highlight.sh /opt/highlight.sh
+
+# You SHOULD run this behind a reverse proxy.
+# Thus, 443 isn't being exposed.
+EXPOSE 80
+CMD [ "httpd", "-DFOREGROUND" ] \ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..3e9f8cd
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016-2021 RATDAD
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE. \ No newline at end of file
diff --git a/cgit.conf b/cgit.conf
new file mode 100644
index 0000000..7fef75d
--- /dev/null
+++ b/cgit.conf
@@ -0,0 +1,7 @@
+##
+## cgit Compiler Options
+## This will be included by the Makefile upon compilation
+
+## Use the standard dir for serving web content
+CGIT_SCRIPT_PATH = /srv/www/htdocs/cgit/
+CGIT_CONFIG = /etc/cgitrc
diff --git a/etc/cgitrc b/etc/cgitrc
new file mode 100644
index 0000000..dad2e2a
--- /dev/null
+++ b/etc/cgitrc
@@ -0,0 +1,57 @@
+#
+# cgit Runtime Configuration
+# see cgitrc(5) for details
+
+#
+# General options
+root-title=Git Repository Browser
+root-desc=a fast webinterface for the git dscm
+robots=noindex, nofollow
+scan-path=/srv/git
+source-filter=/opt/highlight.sh
+
+#
+# Site options
+enable-index-links=1
+enable-remote-branches=1
+enable-log-filecount=1
+enable-log-linecount=1
+enable-git-config=1
+snapshots=tar.gz tar.bz2 zip
+
+#
+# Cache
+cache-root=/var/cache/cgit
+cache-size=1000
+
+#
+# Search for these files in the root of the default branch of repos.
+# This will determine the "about" page for the repo.
+readme=:README.md
+readme=:readme.md
+readme=:README.mkd
+readme=:readme.mkd
+readme=:README.rst
+readme=:readme.rst
+readme=:README.html
+readme=:readme.html
+readme=:README.htm
+readme=:readme.htm
+readme=:README.txt
+readme=:readme.txt
+readme=:README
+readme=:readme
+readme=:INSTALL.md
+readme=:install.md
+readme=:INSTALL.mkd
+readme=:install.mkd
+readme=:INSTALL.rst
+readme=:install.rst
+readme=:INSTALL.html
+readme=:install.html
+readme=:INSTALL.htm
+readme=:install.htm
+readme=:INSTALL.txt
+readme=:install.txt
+readme=:INSTALL
+readme=:install
diff --git a/etc/httpd/httpd.conf b/etc/httpd/httpd.conf
new file mode 100644
index 0000000..d99bd92
--- /dev/null
+++ b/etc/httpd/httpd.conf
@@ -0,0 +1,45 @@
+##
+## Apache Server Configuration
+##
+
+ServerRoot /etc/httpd
+
+#
+# Load Standard Modules
+LoadModule authz_core_module modules/mod_authz_core.so
+LoadModule unixd_module modules/mod_unixd.so
+LoadModule log_config_module modules/mod_log_config.so
+LoadModule logio_module modules/mod_logio.so
+LoadModule mime_magic_module modules/mod_mime_magic.so
+LoadModule mime_module modules/mod_mime.so
+LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
+LoadModule cgi_module modules/mod_cgi.so
+LoadModule dir_module modules/mod_dir.so
+
+#
+# Server config
+Listen 0.0.0.0:80
+ServerName localhost
+ServerAdmin root@localhost
+EnableSendFile on
+AddDefaultCharset UTF-8
+TypesConfig /etc/mime.types
+MIMEMagicFile conf/magic
+
+<Directory />
+ Require all denied
+</Directory>
+
+DocumentRoot "/srv/www/htdocs/cgit"
+<Directory "/srv/www/htdocs/cgit/">
+ DirectoryIndex cgit.cgi
+ AddHandler cgi-script .cgi
+ AllowOverride None
+ Options +ExecCGI -FollowSymLinks
+ Require all granted
+</Directory>
+
+# Future proof
+<Files ".ht">
+ Require all denied
+</Files> \ No newline at end of file
diff --git a/opt/highlight.sh b/opt/highlight.sh
new file mode 100644
index 0000000..13e8ae6
--- /dev/null
+++ b/opt/highlight.sh
@@ -0,0 +1,23 @@
+## This is for syntax highlighting
+# Get the name of the file and the extension of it
+BASENAME="$1"
+EXTENSION="${BASENAME##*.}"
+
+[ "${BASENAME}" = "${EXTENSION}" ] && EXTENSION=txt
+[ -z "${EXTENSION}" ] && EXTENSION=txt
+
+# Makefile and Makefile.* are all .mk
+[ "${BASENAME%%.*}" = "Makefile" ] && EXTENSION=mk
+
+# User note: highlight v2 and v3 have different command options
+# -X is replaced by "-O xhtml" in v3
+
+# If for whatever reason, this container is using EPEL5 (it shouldn't),
+# use the following line instead of the bottom line
+# exec highlight --force -f -I -X -S "$EXTENSION" 2>/dev/null
+
+# EPEL6 version with no inline css
+# exec highlight --force -f -I -O xhtml -S "EXTENSION" 2>/dev/null
+
+# highlight v3 is available on EPEL6
+exec highlight --force --inline-css -f -I -O xhtml -S "EXTENSION" 2>/dev/null \ No newline at end of file