Skip to content

Added cgit container based on CentOS. #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cgit/centos7/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM registry.centos.org/centos/centos:7

MAINTAINER Mohammed Zeeshan Ahmed <[email protected]>

RUN yum -y update && yum clean all

RUN mkdir -p /srv/git /opt/scripts

ADD ./fix-permissions.sh ./install.sh ./passwd.template ./run.sh /opt/scripts/

RUN chmod -R 777 /opt/scripts && . /opt/scripts/install.sh

WORKDIR /srv/git

EXPOSE 8080 8443

USER apache

ENTRYPOINT ["/opt/scripts/run.sh"]
CMD ["cgit"]
1 change: 1 addition & 0 deletions cgit/centos7/cccp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
job-id: cgit
8 changes: 8 additions & 0 deletions cgit/centos7/fix-permissions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
# Fix permissions on the given directory to allow group read/write of
# regular files and execute of directories.
set -eux
find "$1" -exec chown ${2} {} \;
find "$1" -exec chgrp 0 {} \;
find "$1" -exec chmod g+rw {} \;
find "$1" -type d -exec chmod g+x {} +
29 changes: 29 additions & 0 deletions cgit/centos7/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

set -eux;

# Initialize variables
HTTPD_CONF="/etc/httpd/conf/httpd.conf"
HTTPD_WELCOME="/etc/httpd/conf.d/welcome.conf"
CGIT_CONF="/etc/cgitrc"
CGIT_REPOS="/etc/cgitrepos"
INSTALL_PKGS="cgit highlight policycoreutils-python httpd nss_wrapper gettext";

# Setup necessary packages
yum -y install epel-release && yum -y install ${INSTALL_PKGS};

# Fixup Configurations
rm -rf ${HTTPD_WELCOME};
sed -i 's/^Listen 80/Listen 8080\\\nListen 8443/g' ${HTTPD_CONF};
sed -i 's/^Listen 8080\\/Listen 8080/g' ${HTTPD_CONF};
sed -i 's/^Group apache/Group root/g' ${HTTPD_CONF};
echo -e "scan-path=/srv/git\n" >> /etc/cgitrc;
touch ${CGIT_REPOS} && echo -e "include=${CGIT_REPOS}\n" >> /${CGIT_CONF};
mkdir -p /etc/httpd/logs && touch /etc/httpd/logs/error_log && touch /etc/httpd/logs/access_log;

# Fix the permissions
for item in "/srv/git" "/etc/cgitrepos" "/etc/httpd" "/var/www"; do
. /opt/scripts/fix-permissions.sh ${item} apache;
done

chmod -R 777 /etc/httpd/logs
14 changes: 14 additions & 0 deletions cgit/centos7/passwd.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
apache:x:${USER_ID}:${GROUP_ID}:Apache User:${HOME}:/bin/bash
14 changes: 14 additions & 0 deletions cgit/centos7/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

export USER_ID=$(id -u);
export GROUP_ID=$(id -g);
envsubst < /opt/scripts/passwd.template > /tmp/passwd;
export LD_PRELOAD=libnss_wrapper.so;
export NSS_WRAPPER_PASSWD=/tmp/passwd;
export NSS_WRAPPER_GROUP=/etc/group;

if [ $1 == "cgit" ]; then
exec /usr/sbin/httpd -DFOREGROUND;
else
exec $1
fi