Project

General

Profile

Support #679

Updated by Daniel Curtis over 8 years ago

{{>toc}} 

 This is a guide on installing GitLab 8.8 from source 8 with continuous integration on FreeBSD 10. 

 h2. Prepare the Environment 

 * Make sure the system is up to date: 
 <pre> 
 pkg update && pkg upgrade 
 </pre> 

 * Install a few dependencies: 
 <pre> 
 pkg install sudo bash icu cmake pkgconf git node ruby ruby22-gems logrotate postfix krb5 go wget rubygem-bundler portmaster postgresql94-server redis gmake mercurial 
 </pre> 

 * Add the GitLab user 
 <pre> 
 pw add user -n git -m -s /usr/local/bin/bash -c "GitLab" 
 </pre>  

 * Add git to the redis group: 
 <pre> 
 pw usermod git -G redis 
 </pre> 

 * Install a couple gems: 
 <pre> 
 gem install whenever rubocop 
 </pre> 

 h3. Configure Postfix 

 * Enable postfix as the mail delivery agent, and disable sendmail: 
 <pre> 
 echo 'postfix_enable="YES"' >> /etc/rc.conf 
 echo 'sendmail_enable="NO"' >> /etc/rc.conf 
 echo 'sendmail_submit_enable="NO"' >> /etc/rc.conf 
 echo 'sendmail_outbound_enable="NO"' >> /etc/rc.conf 
 echo 'sendmail_msp_queue_enable="NO"' >> /etc/rc.conf 
 </pre> 

 h3. Configure PostgreSQL 

 * Initialize, start, and enable postgresql at boot: 
 <pre> 
 echo 'postgresql_enable="YES"' >> /etc/rc.conf 
 service postgresql initdb 
 service postgresql start 
 </pre> 

 * Log in to postgresql user account 
 <pre> 
 su - pgsql 
 </pre> 

 * Connect to postgresql database 
 <pre> 
 psql -d template1 
 </pre> 
 #* Create a user for GitLab: 
 <pre> 
 CREATE USER git WITH PASSWORD 'SuperSecretPassword' CREATEDB; 
 </pre> 
 #* Create the GitLab production database & grant all privileges on database 
 <pre> 
 CREATE DATABASE gitlabhq_production OWNER git encoding='UTF8'; 
 </pre> 
 #* Quit the database session 
 <pre> 
 \q 
 exit 
 </pre> 

 h3. Configure Redis 

 * Back up the original Redis config file: 
 <pre> 
 cp /usr/local/etc/redis.conf /usr/local/etc/redis.conf.orig 
 </pre> 

 * Disable Redis listening on TCP by setting 'port' to 0 
 <pre> 
 sed -i '' -e 's/^port .*/port 0/' /usr/local/etc/redis.conf 
 </pre> 

 * Enable Redis socket 
 <pre> 
 echo 'unixsocket /usr/local/var/run/redis/redis.sock' >> /usr/local/etc/redis.conf 
 </pre> 

 * Grant permission to the socket to all members of the redis group 
 <pre> 
 echo 'unixsocketperm 770' >> /usr/local/etc/redis.conf 
 </pre> 

 * Create the directory which contains the socket 
 <pre> 
 mkdir -p /usr/local/var/run/redis 
 chown redis:redis /usr/local/var/run/redis 
 chmod 755 /usr/local/var/run/redis 
 </pre> 

 * Start and enable redis at boot: 
 <pre> 
 echo 'redis_enable="YES"' >> /etc/rc.conf 
 service redis start 
 </pre> 

 h2. Install GitLab 8 

 * Switch to the git user: 
 <pre> 
 su - git 
 </pre> 

 * Clone GitLab repository 
 <pre> 
 git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 8-8-stable gitlab 
 cd gitlab 
 </pre> 

 * Copy the example GitLab config 
 <pre> 
 cp config/gitlab.yml.example config/gitlab.yml 
 </pre> 

 * Update GitLab config file, follow the directions at top of file 
 <pre> 
 vi config/gitlab.yml 
 </pre> 

 * Copy the example secrets file 
 <pre> 
 cp config/secrets.yml.example config/secrets.yml 
 chmod 0600 config/secrets.yml 
 </pre> 

 * Make sure GitLab can write to the @log/@ and @tmp/@ directories 
 <pre> 
 chown -R git log/ 
 chown -R git tmp/ 
 chmod -R u+rwX,go-w log/ 
 chmod -R u+rwX tmp/ 
 </pre> 

 * Make sure GitLab can write to the @tmp/pids/@ and @tmp/sockets/@ directories 
 <pre> 
 chmod -R u+rwX tmp/pids/ 
 chmod -R u+rwX tmp/sockets/ 
 </pre> 

 * Make sure GitLab can write to the @public/uploads/@ directory 
 <pre> 
 chmod -R u+rwX    public/uploads 
 </pre> 

 * Change the permissions of the directory where CI build traces are stored 
 <pre> 
 chmod -R u+rwX builds/ 
 </pre> 

 * Copy the example Unicorn config 
 <pre> 
 cp config/unicorn.rb.example config/unicorn.rb 
 </pre> 

 * Copy the example Rack attack config 
 <pre> 
 cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb 
 </pre> 

 * Configure Git global settings for git user, used when editing via web editor 
 <pre> 
 git config --global core.autocrlf input 
 </pre> 

 * Configure Redis connection settings 
 <pre> 
 cp config/resque.yml.example config/resque.yml 
 </pre> 

 * Change the Redis socket path if you are not using the default Debian / Ubuntu configuration 
 <pre> 
 vi config/resque.yml 
 </pre> 
 #* And modify the following parameter: 
 <pre> 
 production: unix:/usr/local/var/run/redis/redis.sock 
 </pre> 

 * Configure GitLab DB Settings: 
 <pre> 
 cp config/database.yml.postgresql config/database.yml 
 </pre> 

 * Change the database credentials if necessary: 
 <pre> 
 vi config/database.yml 
 </pre> 

 * Make config/database.yml readable to git only 
 <pre> 
 chmod o-rwx config/database.yml 
 </pre> 

 * Install the gems for PostgreSQL: 
 <pre> 
 bundle install --deployment --without development test mysql aws kerberos 
 </pre> 

 h3. Install GitLab Shell 

 * Run the installation task for gitlab-shell: 
 <pre> 
 bundle exec rake gitlab:shell:install RAILS_ENV=production 
 </pre> 

 # By default, the gitlab-shell config is generated from your main GitLab config, double check the settings are correct: 
 <pre> 
 vi /home/git/gitlab-shell/config.yml 
 </pre> 

 h3. Install GitLab Workhorse 

 * Install the gitlab workhorse: 
 <pre> 
 cd /home/git 
 git clone https://gitlab.com/gitlab-org/gitlab-workhorse.git 
 cd gitlab-workhorse 
 git checkout 0.6.5 
 make 
 </pre> 

 h3. Initialize Database 

 * Initialize the database: 
 <pre> 
 cd /home/git/gitlab 
 bundle exec rake gitlab:setup RAILS_ENV=production 
 </pre> 

 * Exit out of the git user, back into root: 
 <pre> 
 exit 
 </pre> 

 h3. Install Init Script 

 * Download the init script: 
 <pre> 
 wget -O /usr/local/etc/rc.d/gitlab https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/init/init/freebsd/gitlab-unicorn 
 </pre> 

 * Fix the shell environment for the init script: 
 <pre> 
 sed -i '' -e 's/\#\!\ \/bin\/sh/\#\!\ \/usr\/local\/bin\/bash' /usr/local/etc/rc.d/gitlab 
 </pre> 

 * Make the init script executable: 
 <pre> 
 chmod +x /usr/local/etc/rc.d/gitlab 
 </pre> 

 h3. Check Configuration and Compile Assets 

 * Check the configuration: 
 <pre> 
 cd /home/git/gitlab 
 bundle exec rake gitlab:env:info RAILS_ENV=production 
 </pre> 

 * Compile all of the assets for GitLab: 
 <pre> 
 bundle exec rake assets:precompile RAILS_ENV=production 
 </pre> 

 * Start and enable gitlab at boot: 
 <pre> 
 echo 'gitlab_enable="YES"' >> /etc/rc.conf 
 service gitlab start 
 </pre> 

 h2. Install Nginx 

 * Install nginx: 
 <pre> 
 pkg install nginx 
 </pre> 
 *NOTE*: Make sure to enable *[X]HTTP_GZIP_STATIC* during the nginx configuration 

 * Start and enable nginx at boot: 
 <pre> 
 echo 'nginx_enable="YES"' >> /etc/rc.conf 
 service nginx start 
 </pre> 

 * Create a configuration directory to make managing individual server blocks easier 
 <pre> 
 mkdir /usr/local/etc/nginx/conf.d 
 </pre> 

 * Edit the main nginx config file: 
 <pre> 
 vi /usr/local/etc/nginx/nginx.conf 
 </pre> 
 #* And strip down the config file and add the include statement at the end to make it easier to handle various server blocks: 
 <pre> 
 worker_processes    1; 
 error_log    /var/log/nginx-error.log; 

 events { 
     worker_connections    1024; 
 } 

 http { 
     include         mime.types; 
     default_type    application/octet-stream; 
     sendfile          on; 
     keepalive_timeout    65; 

     # Load config files from the /etc/nginx/conf.d directory 
     include /usr/local/etc/nginx/conf.d/*.conf; 
 } 
 </pre> 

 * Create the gitlab nginx config: 
 <pre> 
 vi /usr/local/etc/nginx/conf.d/gitlab.example.com.conf 
 </pre> 
 #* And add the following: 
 <pre> 
 upstream gitlab-workhorse { 
   server unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket fail_timeout=0; 
 } 

 server { 
   listen 80; 
   server_name gitlab.example.com; 
   server_tokens off; 
   root /home/git/gitlab/public; 
   access_log    /var/log/gitlab.example.com-access.log; 
   error_log     /var/log/gitlab.example.com-error.log; 

   location / { 
     client_max_body_size 0; 
     gzip off; 

     proxy_read_timeout        300; 
     proxy_connect_timeout     300; 
     proxy_redirect            off; 

     proxy_http_version 1.1; 

     proxy_set_header      Host                  $http_host; 
     proxy_set_header      X-Real-IP             $remote_addr; 
     proxy_set_header      X-Forwarded-For       $proxy_add_x_forwarded_for; 
     proxy_set_header      X-Forwarded-Proto     $scheme; 

     proxy_pass http://gitlab-workhorse; 
   } 
 } 
 </pre> 

 h2. Install GitLab Runner 

 * Download the binary for 64-bit systems: 
 <pre> 
 wget -O /usr/local/bin/gitlab-ci-multi-runner https://gitlab-ci-multi-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-ci-multi-runner-freebsd-amd64 
 </pre> 
 #* *NOTE*: If the host architecture is 32-bit download the 386 version of the gitlab runner: 
 <pre> 
 wget -O /usr/local/bin/gitlab-ci-multi-runner https://gitlab-ci-multi-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-ci-multi-runner-freebsd-386 
 </pre> 

 * Give it permissions to execute: 
 <pre> 
 chmod +x /usr/local/bin/gitlab-ci-multi-runner 
 </pre> 

 * Open a web browser and go to http://gitlab.example.com, then log in as the admin user: 
 #* Username *root*, password 5iveL!fe 

 * Next navigate to http://gitlab.example.com/ci/admin/runners to get the token 

 * Then switch to the git user 

 * Finally register the gitlab runner instance: 
 <pre> 
 gitlab-ci-multi-runner register --non-interactive --url "http://gitlab.example.com/ci" --registration-token "5777041dc9651d08ff77" --description "gitlab-ce-ruby-2.1" --executor "shell" builds_dir = "" shell = "bash" 
 </pre> 

 h2. Resources 

 * http://doc.gitlab.com/ce/install/installation.html 
 * https://github.com/gitlabhq/gitlab-recipes/blob/master/install/freebsd/freebsd-10.md 
 * https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/development/README.md

Back