diff options
Diffstat (limited to 'gitolite-cgit')
-rw-r--r-- | gitolite-cgit/Dockerfile | 33 | ||||
-rw-r--r-- | gitolite-cgit/cgit.css | 792 | ||||
-rwxr-xr-x | gitolite-cgit/entrypoint.sh | 178 |
3 files changed, 1003 insertions, 0 deletions
diff --git a/gitolite-cgit/Dockerfile b/gitolite-cgit/Dockerfile new file mode 100644 index 0000000..3dd2d87 --- /dev/null +++ b/gitolite-cgit/Dockerfile @@ -0,0 +1,33 @@ +FROM alpine:latest +LABEL MAINTAINER="heckyel@riseup.net" + +# Install needed packages +RUN set -xe \ + && apk add --no-cache --purge -uU \ + # Install gitolite + gitolite git openssh \ + # install git-daemon + git-daemon \ + # add nginx and cgit + cgit nginx fcgiwrap spawn-fcgi \ + # python 3 pkg for highlight, about page + py3-markdown py3-pygments \ + # Create nginx folder + && mkdir -p /run/nginx \ + # Clean up + && rm -rf /var/cache/apk/* \ + && rm -rf /tmp/* + +# Volume to store all ssh host key +VOLUME [ "/etc/ssh" ] + +# Volume to store Gitolite data, used for Gitolite setup +VOLUME [ "/var/lib/git" ] + +EXPOSE 22 80 9418 +WORKDIR /var/lib/git + +COPY cgit.css /usr/share/webapps/cgit/cgit.css +COPY entrypoint.sh / +RUN chmod u+x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/gitolite-cgit/cgit.css b/gitolite-cgit/cgit.css new file mode 100644 index 0000000..e29a033 --- /dev/null +++ b/gitolite-cgit/cgit.css @@ -0,0 +1,792 @@ +:root { + --background: #333; + --text: #FFF; + --text-hover: #60b0ff; + --text-secundary: #333; + --h1: #FFF; + --h2: #FFF; + --h3: #FFF; + --h4: #FFF; + --h5: #FFF; + --h6: #FFF; +} + +body, table, form { +padding: 0em; +margin: 0em; +} + +body { +font-family: sans-serif; +font-size: 10pt; +color: var(--text); +background: var(--background); +padding: 7px; +} + +a { +color: #60b0ff; +text-decoration: none; +} + +a:hover { +text-decoration: underline; +} + +table { +border-collapse: collapse; +} + +table#header { +width: 100%; +margin-bottom: 1em; +} + + +table#header td.logo { +width: 96px; +} + +table#header td.main { +text-align: left; +font-size: 250%; +padding-left: 10px; +white-space: nowrap; +} + +table#header td.main a { +color: var(--text); +} + +table#header td.form { +text-align: left; +vertical-align: bottom; +padding-right: 1em; +padding-bottom: 2px; +white-space: nowrap; +} + +table#header td.form form, +table#header td.form input, +table#header td.form select { +font-size: 90%; +} + +table#header td.sub { +color: var(--text); +border-top: solid 1px var(--background); +padding-left: 10px; +} + +table.tabs { +border-bottom: solid 3px #60b0ff; +border-collapse: collapse; +margin-top: 2em; +margin-bottom: 0px; +width: 100%; +} + +table.tabs td { +padding: 0px 1em; +vertical-align: bottom; +} + +table.tabs td a { +padding: 2px 0.75em; +color: var(--text); +font-size: 110%; +} + +table.tabs td a.active { +color: var(--text); +background-color: #60b0ff; +} + +table.tabs td.form { +text-align: right; +} + +table.tabs td.form form { +padding-bottom: 2px; +font-size: 90%; +white-space: nowrap; +} + +table.tabs td.form input, +table.tabs td.form select { +font-size: 90%; +} + +div.path { +margin: 0px; +padding: 5px 2em 2px 2em; +color: var(--text); +background-color: #266584; +} + +div.content { +margin: 0px; +padding: 2em; +border-bottom: solid 3px #60b0ff; +} + + +table.list { +width: 100%; +border: none; +border-collapse: collapse; +} + +table.list tr { +background: var(--background); +} + +table.list tr.logheader { +background: var(--background); +} + +table.list tr:hover { +background: var(--background); +} + +table.list tr.nohover:hover { +background: var(--background); +} + +table.list th { +font-weight: bold; +color: var(--text); +/*border-top: dashed 1px #888; +border-bottom: dashed 1px #888;*/ + +padding: 0.1em 0.5em 0.05em 0.5em; +vertical-align: baseline; +} +table.list th a { +color: var(--text); +} + +table.list td { +border: none; +padding: 0.1em 0.5em 0.1em 0.5em; +} + +table.list td.logsubject { +font-family: monospace; +font-weight: bold; +} + +table.list td.logmsg { +font-family: monospace; +white-space: pre; +padding: 1em 0.5em 2em 0.5em; +} + +table.list td.lognotes-label { +text-align:right; +vertical-align:top; +} + +table.list td.lognotes { +font-family: monospace; +white-space: pre; +padding: 0em 0.5em 2em 0.5em; +} + +table.list td a { +color: var(--text); +} + +table.list td .decoration > a { +color: var(--text-secundary); +} + +table.list td a.ls-dir { +font-weight: bold; +color: var(--text); +} + +table.list td a:hover { +color: var(--text-hover); +} + +img { +border: none; +} + +input#switch-btn { +margin: 2px 0px 0px 0px; +} + +td#sidebar input.txt { +width: 100%; +margin: 2px 0px 0px 0px; +} + +table#grid { +margin: 0px; +} + +td#content { +vertical-align: top; +padding: 1em 2em 1em 1em; +border: none; +} + +div#summary { +vertical-align: top; +margin-bottom: 1em; +} + +table#downloads { +float: right; +border-collapse: collapse; +border: solid 1px #777; +margin-left: 0.5em; +margin-bottom: 0.5em; +} + +table#downloads th { +background-color: var(--background); +} + +div#blob { +border: solid 1px var(--text); +} + +div.error { +color: red; +font-weight: bold; +margin: 1em 2em; +} + +a.ls-blob, a.ls-dir, a.ls-mod { +font-family: monospace; +} + +td.ls-size { +text-align: right; +font-family: monospace; +width: 10em; +} + +td.ls-mode { +font-family: monospace; +width: 10em; +} + +table.blob { +margin-top: 0.5em; +border-top: solid 1px var(--text); +} + +table.blob td.lines { +margin: 0; padding: 0 0 0 0.5em; +vertical-align: top; +color: var(--text); +} + +table.blob td.linenumbers { +margin: 0; padding: 0 0.5em 0 0.5em; +vertical-align: top; +text-align: right; +border-right: 1px solid var(--text); +} + +table.blob pre { +padding: 0; margin: 0; +} + +table.blob a.no { +color: var(--text); +text-align: right; +text-decoration: none; +} + +table.blob a.no a:hover { +color: var(--text); +} + +table.bin-blob { +margin-top: 0.5em; +border: solid 1px var(--text); +} + +table.bin-blob th { +font-family: monospace; +white-space: pre; +border: solid 1px var(--text); +padding: 0.5em 1em; +} + +table.bin-blob td { +font-family: monospace; +white-space: pre; +border-left: solid 1px var(--text); +padding: 0em 1em; +} + +table.nowrap td { +white-space: nowrap; +} + +table.commit-info { +border-collapse: collapse; +margin-top: 1.5em; +} + +table.commit-info th { +text-align: left; +font-weight: normal; +padding: 0.1em 1em 0.1em 0.1em; +vertical-align: top; +} + +table.commit-info td { +font-weight: normal; +padding: 0.1em 1em 0.1em 0.1em; +} + +div.commit-subject { +font-weight: bold; +font-size: 125%; +margin: 1.5em 0em 0.5em 0em; +padding: 0em; +} + +div.commit-msg { +white-space: pre; +font-family: monospace; +} + +div.notes-header { +font-weight: bold; +padding-top: 1.5em; +} + +div.notes { +white-space: pre; +font-family: monospace; +border: solid 1px #ee9; +background-color: var(--background); +padding: 0.3em 2em 0.3em 1em; +float: left; +} + +div.notes-footer { +clear: left; +} + +div.diffstat-header { +font-weight: bold; +padding-top: 1.5em; +} + +table.diffstat { +border-collapse: collapse; +border: solid 1px var(--text); +background-color: var(--background); +} + +table.diffstat th { +font-weight: normal; +text-align: left; +text-decoration: underline; +padding: 0.1em 1em 0.1em 0.1em; +font-size: 100%; +} + +table.diffstat td { +padding: 0.2em 0.2em 0.1em 0.1em; +font-size: 100%; +border: none; +} + +table.diffstat td.mode { +white-space: nowrap; +} + +table.diffstat td span.modechange { +padding-left: 1em; +color: red; +} + +table.diffstat td.add a { +color: green; +} + +table.diffstat td.del a { +color: red; +} + +table.diffstat td.upd a { +/* color: blue; */ +} + +table.diffstat td.graph { +width: 500px; +vertical-align: middle; +} + +table.diffstat td.graph table { +border: none; +} + +table.diffstat td.graph td { +padding: 0px; +border: 0px; +height: 7pt; +} + +table.diffstat td.graph td.add { +background-color: #5c5; +} + +table.diffstat td.graph td.rem { +background-color: #c55; +} + +div.diffstat-summary { +color: var(--text); +padding-top: 0.5em; +} + +table.diff { +width: 100%; +} + +table.diff td { +font-family: monospace; +white-space: pre; +} + +table.diff td div.head { +font-weight: bold; +margin-top: 1em; +color: var(--text); +} + +table.diff td div.hunk { +color: #6CC; +} + +table.diff td div.add { +color: #2bb34b; +} + +table.diff td div.del { +color: red; +} + +.sha1 { +font-family: monospace; +font-size: 90%; +} + +.left { +text-align: left; +} + +.right { +text-align: right; +} + +table.list td.reposection { +font-style: italic; +color: var(--text); +} + +a.button { +font-size: 80%; +padding: 0em 0.5em; +} + +a.primary { +font-size: 100%; +} + +a.secondary { +font-size: 90%; +} + +td.toplevel-repo { + +} + +table.list td.sublevel-repo { +padding-left: 1.5em; +} + +div.pager { +text-align: center; +margin: 1em 0em 0em 0em; +} + +div.pager a { +color: var(--text); +margin: 0em 0.5em; +} + +span.age-mins { +font-weight: bold; +color: #0c0; +} + +span.age-hours { +color: #0c0; +} + +span.age-days { +color: #080; +} + +span.age-weeks { +color: #bbb; +} + +span.age-months { +color: #888; +} + +span.age-years { +color: #666; +} +div.footer { +margin-top: 0.5em; +text-align: center; +font-size: 80%; +color: #ccc; +} +table.list td a.branch-deco { +color: var(--text-secundary); +} +.decoration a.branch-deco { +color: #444; +} +.decoration a.deco { +color: var(--text); +} +a.branch-deco { +margin: 0px 0.5em; +padding: 0px 0.25em; +background-color: #00ff00; +border: solid 1px #00ff00; +} +table.list td a.tag-deco { +color: var(--text); +} +a.tag-annotated-deco { +margin: 0px 0.5em; +padding: 0px 0.25em; +background-color: #ffff00; +border: solid 1px #ffff00; +} + +a.tag-deco { +margin: 0px 0.5em; +padding: 0px 0.25em; +background-color: #ffff00; +border: solid 1px #ffff00; +} +table.list td a.remote-deco { +color: var(--text); +} +a.remote-deco { +margin: 0px 0.5em; +padding: 0px 0.25em; +background-color: #0000ff; +border: solid 1px #0000ff; +} +table.list td a.deco { +color: var(--text); +} +a.deco { +margin: 0px 0.5em; +padding: 0px 0.25em; +background-color: #ff0000; +border: solid 1px #ff0000; +} + +div.commit-subject a.branch-deco, +div.commit-subject a.tag-deco, +div.commit-subject a.remote-deco, +div.commit-subject a.deco { +margin-left: 1em; +font-size: 75%; +} + +table.stats { +border: solid 1px var(--text); +border-collapse: collapse; +} + +table.stats th { +text-align: left; +padding: 1px 0.5em; +background-color: #555; +border: solid 1px var(--text); +} + +table.stats td { +text-align: right; +padding: 1px 0.5em; +border: solid 1px var(--text); +} + +table.stats td.total { +font-weight: bold; +text-align: left; +} + +table.stats td.sum { +color: #c00; +font-weight: bold; +} + +table.stats td.left { +text-align: left; +} + +table.vgraph { +border-collapse: separate; +border: solid 1px var(--text); +height: 200px; +} + +table.vgraph th { +background-color: var(--background); +font-weight: bold; +border: solid 1px var(--text); +padding: 1px 0.5em; +} + +table.vgraph td { +vertical-align: bottom; +padding: 0px 10px; +} + +table.vgraph div.bar { +background-color: var(--background); +} + +table.hgraph { +border: solid 1px var(--text); +width: 800px; +} + +table.hgraph th { +background-color: #eee; +font-weight: bold; +border: solid 1px var(--text); +padding: 1px 0.5em; +} + +table.hgraph td { +vertical-align: center; +padding: 2px 2px; +} + +table.hgraph div.bar { +background-color: var(--background); +height: 1em; +} + +table.ssdiff { +width: 100%; +} + +table.ssdiff td { +font-size: 75%; +font-family: monospace; +white-space: pre; +padding: 1px 4px 1px 4px; +border-left: solid 1px #aaa; +border-right: solid 1px #aaa; +} + +table.ssdiff td.add { +color: var(--text); +background: #cfc; +min-width: 50%; +} + +table.ssdiff td.add_dark { +color: var(--text); +background: #aca; +min-width: 50%; +} + +table.ssdiff span.add { +background: #cfc; +font-weight: bold; +} + +table.ssdiff td.del { +color: var(--text); +background: #fcc; +min-width: 50%; +} + +table.ssdiff td.del_dark { +color: var(--text); +background: #caa; +min-width: 50%; +} + +table.ssdiff span.del { +background: #fcc; +font-weight: bold; +} + +table.ssdiff td.changed { +color: var(--text); +background: #ffc; +min-width: 50%; +} + +table.ssdiff td.changed_dark { +color: var(--text); +background: #cca; +min-width: 50%; +} + +table.ssdiff td.lineno { +color: var(--text); +background: #eee; +text-align: right; +width: 3em; +min-width: 3em; +} + +table.ssdiff td.hunk { +color: var(--text); +background: #ccf; +border-top: solid 1px #aaa; +border-bottom: solid 1px #aaa; +} + +table.ssdiff td.head { +border-top: solid 1px #aaa; +border-bottom: solid 1px #aaa; +} + +table.ssdiff td.head div.head { +font-weight: bold; +color: var(--text); +} + +table.ssdiff td.foot { +border-top: solid 1px #aaa; +border-left: none; +border-right: none; +border-bottom: none; +} + +table.ssdiff td.space { +border: none; +} + +table.ssdiff td.space div { +min-height: 3em; +} + diff --git a/gitolite-cgit/entrypoint.sh b/gitolite-cgit/entrypoint.sh new file mode 100755 index 0000000..524a502 --- /dev/null +++ b/gitolite-cgit/entrypoint.sh @@ -0,0 +1,178 @@ +#!/bin/bash + +# Validate environment variables + +# Create ssh host key if not present +if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then + ssh-keygen -A +fi + +# Setup gitolite at volume /var/lib/git +if [ ! -f "/var/lib/git/.ssh/authorized_keys" ]; then + # Configure gitolite + echo "$SSH_KEY" > "/tmp/$SSH_KEY_NAME.pub" + su git -c "gitolite setup -pk \"/tmp/$SSH_KEY_NAME.pub\"" + rm "/tmp/$SSH_KEY_NAME.pub" +fi + +# Init container +if [ ! -f /etc/nginx/conf.d/cgit.conf ]; then + # enable random git password + GIT_PASSWORD=$(date +%s | sha256sum | base64 | head -c 32) + echo "git:$GIT_PASSWORD" | chpasswd + + # add web user (nginx) to gitolite group (git) + adduser nginx git + + ## Config cgit interface + cat > /etc/cgitrc <<- EOF +# Use a virtual-root +virtual-root=/ + +# Enable caching of up to 1000 output entries +cache-size=1000 + +# Specify the css url +css=/cgit.css + +# Show extra links for each repository on the index page +enable-index-links=1 + +# Enable ASCII art commit history graph on the log pages +enable-commit-graph=1 + +# Show number of affected files per commit on the log pages +enable-log-filecount=1 + +# Show number of added/removed lines per commit on the log pages +enable-log-linecount=1 + +# Use a custom logo +logo=/cgit.png + +# Enable statistics per week, month and quarter +max-stats=quarter + +## +## List of common mimetypes +## + +mimetype.gif=image/gif +mimetype.html=text/html +mimetype.jpg=image/jpeg +mimetype.jpeg=image/jpeg +mimetype.pdf=application/pdf +mimetype.png=image/png +mimetype.svg=image/svg+xml + +# Enable syntax highlighting and about formatting +source-filter=/usr/lib/cgit/filters/syntax-highlighting.py +about-filter=/usr/lib/cgit/filters/about-formatting.sh + +## +## List of common readmes +## +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 + +# Direct cgit to repository location managed by gitolite +remove-suffix=0 +project-list=/var/lib/git/projects.list +section-from-path=3 +scan-path=/var/lib/git/repositories +EOF + + # Append clone-prefix + if [[ ! -z "$CGIT_CLONE_PREFIX" ]]; then + echo "# Specify some default clone prefixes" >> /etc/cgitrc + echo "clone-prefix=$CGIT_CLONE_PREFIX" >> /etc/cgitrc + fi + + if [[ ! -z "$CGIT_ROOT_TITLE" ]]; then + echo "# Set the title and heading of the repository index page" >> /etc/cgitrc + echo "root-title=$CGIT_ROOT_TITLE" >> /etc/cgitrc + fi + + if [[ ! -z "$CGIT_DESC" ]]; then + echo "# Set description repository" >> /etc/cgitrc + echo "root-desc=$CGIT_DESC" >> /etc/cgitrc + fi + + if [[ ! -z "$CGIT_SNAPSHOT" ]]; then + echo "# Allow download of tar.gz, tar.bz2, and tar.xz formats" >> /etc/cgitrc + echo "snapshots=$CGIT_SNAPSHOT" >> /etc/cgitrc + fi + + # Using highlight syntax + #sed -i.bak \ + # -e "s#exec highlight --force -f -I -X -S #\#&#g" \ + # -e "s#\#exec highlight --force -f -I -O xhtml#exec highlight --force --inline-css -f -I -O xhtml#g" \ + # /usr/lib/cgit/filters/syntax-highlighting.sh + + # Nginx configuration + rm /etc/nginx/conf.d/default.conf + + cat > /etc/nginx/conf.d/cgit.conf <<- EOF + server { + listen 80 default_server; + server_name localhost; + + root /usr/share/webapps/cgit; + try_files \$uri @cgit; + + location ~* ^.+\.(css|png|ico)$ { + expires 30d; + } + + location / { + index cgit.cgi; + fastcgi_param SCRIPT_FILENAME \$document_root/cgit.cgi; + fastcgi_pass unix:/run/fcgiwrap/fcgiwrap.socket; + fastcgi_param HTTP_HOST \$server_name; + fastcgi_param PATH_INFO \$uri; + fastcgi_param QUERY_INFO \$uri; + include "fastcgi_params"; + } + } +EOF + +fi + +# Start sshd as detach, log to stderr (-e) +/usr/sbin/sshd -e + +# launch fcgiwrap via spawn-fcgi, port 1234 +spawn-fcgi -s /run/fcgiwrap/fcgiwrap.socket -f /usr/bin/fcgiwrap +chmod 660 /run/fcgiwrap/fcgiwrap.socket + +# Start git-daemon +git daemon --detach --reuseaddr --base-path=/var/lib/git/repositories /var/lib/git/repositories + +# Start nginx +exec nginx -g "daemon off;" |