Gitlab
Gitlab is built overtop of the git SourceControlManager. It offers github-inspired project-management for teams.
NOTE:
Unless otherwise specified, when listing the contents of a configfile, I am only naming the key-values that have been modified from the default
Install
FreeBSD
NOTE:
The following recipe was extremely helpful (neither the binary, nor the port were working) https://github.com/gitlabhq/gitlab-recipes/blob/master/install/freebsd/freebsd-10.md
Dependencies
sudo -i ## login as root ## install dependencies pkg install \ bash \ openssh \ icu \ cmake \ pkgconf \ git \ nginx \ node \ ruby \ ruby22-gems \ logrotate \ redis \ postgresql95-server \ postgresql95-contrib \ postfix \ krb5 \ gmake \ go ## install ruby-bundler system-wide gem install bundler --no-ri --no-rdoc ## create default database & start service postgresql initdb service postgresql start
/etc/rc.conf
hostname="tmagitlab.domain.com" ## requires a FQDN for postfix redis_enable="YES" postgresql_enable="YES" gitlab_enable="YES" nginx_enable="YES"User Setup
## create user 'git' to run gitlab and access repositories pw add user -n git -m -s /usr/local/bin/bash -c "GitLab" pw groupmod redis -m git ## add 'git' user to group 'redis' pw groupmod git -m www ## add 'www' user to group 'git' chmod 750 /home/gitClone Gitlab/Workhorse
cd /home/git sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 8-10-stable gitlab sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-workhorse
redis
cp /usr/local/etc/redis.conf /usr/local/etc/redis.conf.orig ## keep a backup of default ## create dir for pidfile mkdir -p /usr/local/var/run/redis chown redis:redis /usr/local/var/run/redis#### /usr/local/etc/redis.conf port 0 unixsocet /usr/local/var/run/redis/redis.sock unixsocketperm 770sudo service redis restartgitlab config
Default Configs
cd /home/git/gitlab sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb sudo -u git -H cp config/resque.yml.example config/resque.yml sudo -u git -H cp config/database.yml.postgresql config/database.yml ## since we're using postgres sudo -u git -H cp config/secrets.yml.example config/secrets.yml chmod 600 config/secrets.yml ## readable by owner only
Permissionscd /home/git/gitlab chown -R git gitlab/log chmod -R 775 gitlab/log chown -R git gitlab/tmp chmod -R 775 gitlab/tmp chmod 775 tmp/pids chmod 775 tmp/sockets sudo -u git -H mkdir public/uploads chmod 700 public/uploads chmod 775 builds chmod 775 shared/artifacts chmod 777 config/database.yml#### /home/git/gitlab/config/gitlab.yml production: &base gitlab: host: tmagitlab.domain.com ## your FQDN git: bin_path: /usr/local/bin/git # NOTE: search/replace all '/home/git' to '/s/home/git'Download the official initscript for FreeBSD (even if the binary won't run, it's initscript still works :) )
fetch -o /usr/local/etc/rc.d/gitlab https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/init/init/freebsd/gitlab-unicorn chmod 555 /usr/local/etc/rc.d/gitlab
#### /home/git/gitlab/config/resque.yml production: unix:/usr/local/var/run/redis/redis.sockGit Settings
sudo -u git -H git config --global core.autocrlf input ## because windows is incompatible with *EVERYTHING* sudo -u git -H git config --global gc.auto 0 ## gitlab handles garbage-collectionGitlab Workhorse
Used to manage slow HTTP connections (required).
cd /home/git/gitlab-workhorse sudo -u git -H git checkout v0.7.9 sudo -u git -H gmakeGitlab Shell
Required by installer, presumably allows you to use a web-based console?
sudo -u git -H mkdir /home/git/repositories ## a place for your git repos cd /home/git/gitlab sudo -u git -H bundle exec rake gitlab:shell:install REDIS_URL=unix:/usr/local/var/run/redis/redis.sock RAILS_ENV=production#### /home/git/gitlab-shell/config.yml # search/replace all '/home/git' to '/s/home/git' gitlab_url: http://localhost:8080
Database Setup
service postgresql initdb ## create default database service postgresql start ## initial setup of database for gitlab psql -U pgsql -d template1 -c "CREATE USER git CREATEDB;" psql -U pgsql -d template1 -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;" psql -U pgsql -d template1 -c "CREATE DATABASE gitlabhq_production OWNER git encoding='UTF8';" ## populate database cd /home/git/gitlab sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=<yourpassword>Compile Gitlab!
Check Configuration (run, and see if any errors came up).
cd /home/git/gitlab sudo -u git3 -H bundle exec rake gtlab:env:info RAILS_ENV=productionCompile Gitlab
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=productionStart Gitlab
service gitlab start # there should be no errors/warningsNginX
Setup gitlab's webserver.
mkdir -p /usr/local/etc/nginx/conf.d mkdir -p /usr/local/etc/nginx/ssl mkdir -p /var/log/nginxDownload a base-config (choose one of either SSL or HTTP)
## SSL setup fetch -o /usr/local/etc/nginx/conf.d/gitlab.conf https://gitlab.com/gitlab-org/gitlab-ce/raw/master/lib/support/nginx/gitlab-ssl ## HTTP setup fetch -o /usr/local/etc/nginx/conf.d/gitlab.conf https://gitlab.com/gitlab-org/gitlab-ce/raw/master/lib/support/nginx/gitlabReplace entire configfile (although basically we are adding the line
include /usr/local/etc/nginx/conf.d/*;
).#### /usr/local/etc/nginx/nginx.conf load_module /usr/local/libexec/nginx/ngx_mail_module.so; load_module /usr/local/libexec/nginx/ngx_stream_module.so; user www; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; include /usr/local/etc/nginx/conf.d/*; }Modify the downloaded
conf.d/gitlab.conf
(this may vary a little as they update it).# search/replace '/home' with '/s/home' # search/replace '/etc' with '/usr/local/etc' # search/replace 'YOUR_SERVER_FQDN' with 'tmagitlab.domain.com' (or your FQDN) # comment out all 'listen' lines, and replace with listen 0.0.0.0:80;
Start nginx (and check for any configuration errors during startup).service nginx startTest Gitlab
At this point your gitlab install should be running. try visiting it from your local network in a web-browser.
If you are experiencing difficulties, check out nginx's logs to try to decipher what is going on.Usage
Configuration