Minimal git Infrastructure: Difference between revisions

From Run Your Own
Jump to navigation Jump to search
Line 61: Line 61:
== Usage ==
== Usage ==
=== Create a new repos on the git server ===
=== Create a new repos on the git server ===
This can be done by any user in the group <code>gitusers</code>:
This can be done by any user in the group <code>gitusers</code>, not need to be root:
  cd /var/www/git.lurk.org
  cd /var/www/git.lurk.org
  ./new_repos.sh name-of-the-repos "oneline about the repos"
  ./new_repos.sh name-of-the-repos "oneline about the repos"

Revision as of 21:19, 1 August 2019

Goal: To run your own minimal git infrastructure exclusively for your shell users (sorry no guest, no wiki, no issue tracker, and send patches via email plz or GTFO), making use of ancient ACL magic, and providing a web interface with stagit for public repos browsing and anonymous read-only clone/pull. In this example we use LURK's domain name and server setup as an example.

Prerequisites

Installs

  • Install libgit2 headers and ACL tools, on Debian:
apt install libgit2-dev acl
  • Compile and install stagit, a static git page generator:
cd /usr/src
git clone git://git.codemadness.org/stagit
cd stagit
# Optional: edit stagit-index.c to customize some settings like the site header, etc.
make && make install

configs

We need two directories, one for serving the public static files, and one for keeping the bare git repositories.

  • create these directories for your repos and for stagit:
mkdir -p /var/www/git.lurk.org/repos
  • Get a style
cp /usr/src/stagit/style.css /var/www/git.lurk.org
# Optional: further stylify style.css
  • Get a logo
 wget https://things.bleu255.com/runyourown/images/d/d5/Runyourown.png -O /var/www/git.lurk.org/logo.png
addgroup gitusers
  • Give this group the permissions to modify each others files in the git folders:
setfacl -Rm g:gitusers:rwX /var/www/git.lurk.org/
setfacl -d -Rm g:gitusers:rwX /var/www/git.lurk.org/
  • Add the local users who should have access to full read-write access to the gitusers group:
adduser alice gitusers
adduser bob gitusers
# etc...
  • Create a new nginx site config for the static website in /etc/nginx/sites-enabled/sites-available/git.lurk.org:
server {
  listen 443;

  server_name git.lurk.org;

  root /var/www/git.lurk.org/;
  autoindex on;

  access_log /var/log/nginx/git.lurk.org-access.log;
  error_log /var/log/nginx/git.lurk.org-error.log;
}
  • Enable it and reload nginx:
ln -s /etc/nginx/sites-available/git.lurk.org /etc/nginx/sites-enabled/
service nginx reload

DONE! Now you should make some repos :)

Usage

Create a new repos on the git server

This can be done by any user in the group gitusers, not need to be root:

cd /var/www/git.lurk.org
./new_repos.sh name-of-the-repos "oneline about the repos"

Create local repos and set the git server as origin

On your machine and *after the repos on the git server was created*:

mkdir name-of-the-repos
cd name-of-the-repos
git init
# now add and git commit some files
git remote add origin server-name:/var/www/git.lurk.org/repos/name-of-the-repos.git
git push --set-upstream origin master

Clone existing repos to contribute

git clone server-name:/var/www/git.lurk.org/repos/name-of-the-repos.git