Skip to content

Commit 37d3c6b

Browse files
author
James Hanlon
committed
Finish implementation.
1 parent b860ab7 commit 37d3c6b

File tree

6 files changed

+131
-3
lines changed

6 files changed

+131
-3
lines changed

Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ RUN ln -s /usr/share/gitweb /opt/www
1010

1111
RUN rm -v /etc/nginx/nginx.conf
1212
ADD nginx.conf /etc/nginx
13+
ADD gitweb.conf /etc/gitweb.conf
14+
15+
CMD spawn-fcgi -s /var/run/fcgiwrap.socket /usr/sbin/fcgiwrap && \
16+
nginx "-g" "daemon off;"

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Gitweb served by FCGI and Nginx in a container.
2+
3+
Build and run:
4+
5+
docker-compose build
6+
docker-compose up

docker-compose.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ version: '2'
22
services:
33
gitweb:
44
build: .
5+
volumes:
6+
- ../repos:/opt/repos
57
ports:
6-
- "5000:5000"
8+
- "80:80"

gitweb.conf

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# path to git projects (<project>.git)
2+
$projectroot = "/opt/repos";
3+
4+
$site_name = "git.jwhanlon.com";
5+
6+
# directory to use for temp files
7+
$git_temp = "/tmp";
8+
9+
# target of the home link on top of all pages
10+
$home_link = $my_uri || "/";
11+
12+
# html text to include at home page
13+
$home_text = "indextext.html";
14+
15+
# file with project list; by default, simply scan the projectroot dir.
16+
$projects_list = $projectroot;
17+
18+
# stylesheet to use
19+
@stylesheets = ("static/gitweb.css");
20+
21+
# javascript code for gitweb
22+
$javascript = "static/gitweb.js";
23+
24+
# logo to use
25+
$logo = "static/git-logo.png";
26+
27+
# the 'favicon'
28+
$favicon = "static/git-favicon.png";
29+
30+
# git-diff-tree(1) options to use for generated patches
31+
#@diff_opts = ("-M");
32+
@diff_opts = ();

newgit.sh

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
3+
# this script is based on code from the following blog post
4+
# http://arvinderkang.com/2010/08/25/hosting-git-repositories-on-dreamhost/
5+
# and http://gist.github.com/73622
6+
7+
set -e
8+
9+
# Please, configure a default GIT_REPOS_ROOT to match your config
10+
#GIT_REPOS_ROOT="~/private_repos/"
11+
12+
DEFAULT_DESCRIPTION='no description :('
13+
14+
# describe how the script works
15+
usage()
16+
{
17+
echo "Usage: $0 [ -h ] [ -r directory] [ -d description ] [ -n projectname ]"
18+
echo ""
19+
echo "If no projectname is given, the name of the parent folder will be used as project name."
20+
echo ""
21+
echo " -r directory : (root) directory holding your git repositories"
22+
echo " -d description : description for gitweb"
23+
echo " -h : print this screen"
24+
echo " -n name : name of the project (should end in .git)"
25+
echo ""
26+
}
27+
28+
DESCRIPTION=${DEFAULT_DESCRIPTION}
29+
30+
# evaluate the options passed on the command line
31+
while getopts r:d:n:h option
32+
do
33+
case "${option}"
34+
in
35+
r) GIT_REPOS_ROOT=${OPTARG};;
36+
d) DESCRIPTION=${OPTARG};;
37+
n) REPONAME=${OPTARG};;
38+
h) usage
39+
exit 1;;
40+
esac
41+
done
42+
43+
# check if repositories directory is given and is accessible
44+
if [ -z $GIT_REPOS_ROOT ]; then
45+
usage
46+
exit 1
47+
fi
48+
if ! [ -d $GIT_REPOS_ROOT ]; then
49+
echo "ERROR: '${GIT_REPOS_ROOT}' is not a directory"
50+
echo ""
51+
usage
52+
exit 1
53+
fi
54+
55+
# check if name of repository is given. if not, use folder name
56+
if [ -z $REPONAME ]; then
57+
REPONAME=$(basename $PWD)
58+
fi
59+
60+
# Add .git at and if needed
61+
if ! ( echo $REPONAME | grep -q '\.git$'); then
62+
REPONAME="${REPONAME}.git"
63+
fi
64+
65+
#
66+
# Ready to go
67+
#
68+
69+
REP_DIR="${GIT_REPOS_ROOT}/${REPONAME}"
70+
mkdir ${REP_DIR}
71+
pushd ${REP_DIR}
72+
git --bare init
73+
git --bare update-server-info
74+
cp hooks/post-update.sample hooks/post-update
75+
chmod a+x hooks/post-update
76+
echo $DESCRIPTION > description
77+
# This mark the repository as exportable.
78+
# For more info refer to git-http-backend manpage
79+
touch git-daemon-export-ok
80+
popd
81+
exit 0

nginx.conf

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
user www-data;
1+
user root;
22

33
worker_processes 1;
44

@@ -20,10 +20,13 @@ http {
2020
root /opt/www;
2121
location / {
2222
fastcgi_pass unix:/var/run/fcgiwrap.socket;
23-
include fastcgi_params;
2423
fastcgi_param SCRIPT_FILENAME /opt/www/gitweb.cgi;
2524
fastcgi_param PATH_INFO $uri;
2625
fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
26+
include fastcgi_params;
27+
gzip off;
28+
}
29+
location /static {
2730
}
2831
}
2932
}

0 commit comments

Comments
 (0)