Skip to content
jirutka edited this page Dec 27, 2012 · 10 revisions

For Gentoo, you can use our ebuild which makes deploying GitLab easy as a pie. Most of the hard work will do its config script. This ebuild also contains some unofficial fixes and our optional enhancements (e.g. internally public projects support) which you can enable by USE flags.

Preparation

Since the ebuild is not in the official Portage tree, you have to add an overlay repository to your Portage tree. You can manage multiple overlays using Layman.

If you haven’t used layman yet, just run these commands:

echo "app-portage/layman git" >> /etc/portage/package.use
emerge -va layman
echo "source /var/lib/layman/make.conf" >> /etc/make.conf

Then add our CVUT Overlay:

layman -o https://raw.github.com/cvut/gentoo-overlay/master/overlay.xml -f -a cvut

GitLab installation

  1. Unmask some packages:
echo "# Gitlab
www-apps/gitlabhq::cvut ~amd64
=dev-vcs/gitolite-3*::cvut ~amd64
=dev-ruby/bundler-1* ~amd64
net-libs/nodejs ~amd64" >> /etc/portage/package.keywords
  1. Decide what USE flags do you want to use (run equery uses gitlabhq for more information) and specify it in /etc/portage/package.use.

  2. Run emerge -va gitlabhq and after emerge completes, read post-install message for next instructions (srsly, read it!). Don’t be afraid, you just need to edit two configuration files, create database and then run emerge --config which will do the rest (incl. Gitolite configuration)! Don’t forget to start Redis before running config: rc-config start redis.

  3. Add GitLab and Redis to runlevel:

rc-update add gitlab-4.0 default
rc-update add redis default
  1. Configure your web server.

Nginx + Passenger

Note: You should disable USE flag unicorn if you want to use Passenger.

Nginx is a lightweight HTTP server and reverse proxy. Phusion Passenger is an Nginx module, which makes deploying Ruby on Rails applications on Nginx a breeze. In my opinion and many others, it’s the best platform for Ruby on Rails applications.

To install it, you will need to compile Nginx with Passenger module. There’s no official Nginx ebuild with Passenger support, but, you guessed it, there's one in CVUT Overlay.

  1. Unmask package:
bash echo '=www-servers/nginx-1*::cvut ~amd64' >> /etc/portage/package.keywords
  1. Enable nginx modules:
echo 'NGINX_MODULES_HTTP="access gzip gzip_static passenger proxy rewrite stub_status"' >> /etc/make.conf
  1. Install it:
emerge -va www-servers/nginx::cvut
  1. Configure server for your GitLab instance. There’s some inspiration how to do that: /etc/nginx/sites/gitlab.conf:
server {
    listen          [::]:443;
    server_name     gitlab.example.org;

    root            /opt/gitlab-4.0/public;

    access_log      /var/log/nginx/gitlab.access.log main;
    error_log       /var/log/nginx/gitlab.error.log warn;

    ssl on;
    ssl_certificate     /etc/ssl/nginx/nginx.crt;
    ssl_certificate_key /etc/ssl/nginx/nginx.key;

    passenger_user          gitlab;
    passenger_group         gitlab;
    passenger_min_instances 3;

    # Server favicon.ico without logging and tell clients to cache it
    include incl/handle_favicon.conf;

    # Serve precompiled assets directly
    location /assets {
        gzip_static on;
        expires     max;
        add_header  Cache-Control public;
        add_header  Last-Modified "";
        add_header  ETag "";

        try_files $uri @gitlab;
    }

    location / {
        # serve static files from defined root folder
        try_files $uri $uri/index.html $uri.html @gitlab;
    }

    # If a file which is not found in the root folder is requested, 
    # then pass to passenger
    location @gitlab {
        passenger_enabled on;
    }
}

server {
    listen          [::]:80;
    server_name     gitlab.example.org;

    rewrite         ^ https://$server_name$request_uri? permanent;
}
  1. Add Nginx to runlevel and start it:
rc-update add nginx default
rc-config start nginx

Don’t forget to start gitlab-4.0 as well, this script starts Resque for GitLab (and a Unicorn server if you didn’t disable unicorn USE flag!):

rc-config start gitlab-4.0

Nginx + Unicorn

TODO

Final notes

Note that GitLab is not officially supported under Gentoo. However, if you run into any problem with the ebuild or this HOWTO, please open an Issue.

Clone this wiki locally