summaryrefslogtreecommitdiff
path: root/docker/cgit
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-09-17 14:34:50 +0200
committerDaniel Weipert <code@drogueronin.de>2023-09-17 14:34:50 +0200
commit00f8fd8a71ad956dda0e90a42f947f1f805585dc (patch)
treec49d959f60cc4a57c34d62c2cab3cfde6046f82e /docker/cgit
inital commit
Diffstat (limited to 'docker/cgit')
-rw-r--r--docker/cgit/Dockerfile23
-rwxr-xr-xdocker/cgit/docker-entrypoint.sh14
-rwxr-xr-xdocker/cgit/docker-init.py22
3 files changed, 59 insertions, 0 deletions
diff --git a/docker/cgit/Dockerfile b/docker/cgit/Dockerfile
new file mode 100644
index 0000000..187cf10
--- /dev/null
+++ b/docker/cgit/Dockerfile
@@ -0,0 +1,23 @@
+FROM httpd
+
+
+EXPOSE 80
+EXPOSE 443
+
+
+ARG DEBIAN_FRONTEND=noninteractive
+RUN apt-get update
+
+RUN apt-get install -y \
+ cgit \
+ python3
+
+RUN : \
+ && a2enmod cgi
+
+
+COPY docker-init.py /
+COPY docker-entrypoint.sh /
+
+ENTRYPOINT ["/docker-entrypoint.sh"]
+CMD ["init"]
diff --git a/docker/cgit/docker-entrypoint.sh b/docker/cgit/docker-entrypoint.sh
new file mode 100755
index 0000000..102d46c
--- /dev/null
+++ b/docker/cgit/docker-entrypoint.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+
+if [ "${1}" = "init" ]; then
+ service apache2 start
+
+ /docker-init.py
+
+ # TODO: https://git-scm.com/docs/gitweb#_generating_projects_list_using_gitweb
+
+ tail -f /dev/null
+else
+ exec "$@"
+fi
diff --git a/docker/cgit/docker-init.py b/docker/cgit/docker-init.py
new file mode 100755
index 0000000..c5b47b8
--- /dev/null
+++ b/docker/cgit/docker-init.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+
+
+import sys, os
+import re
+
+
+with open("/etc/cgitrc", "r") as file: cgitrc = file.read()
+
+
+for env_name, env_value in os.environ.items():
+ if env_name.startswith('CGIT_'):
+ rc_name = env_name[5:].lower().replace('_', '-')
+ p = re.compile(r"({0}=)([\w\d]+)".format(rc_name))
+
+ if p.search(cgitrc):
+ cgitrc = p.sub(r"\1{0}".format(env_value), cgitrc)
+ else:
+ cgitrc += ("\n" + "{0}={1}".format(rc_name, env_value) + "\n")
+
+
+with open("/etc/cgitrc", "w") as file: file.write(cgitrc)