Skip to content

Installation Instructions

Aditya Prakash edited this page Dec 26, 2015 · 20 revisions

Requirements

Installation from source should work on all major Unix distributions. Following guide is created and tested for Fedora 21 and above. We don't support Windows.

Ruby version

GlitterGallery requires Ruby (MRI) 2.0 or above. You will have to use the standard MRI implementation of Ruby.

Hardware requirements

Storage

Storage size largely depends on size of projects you plan on hosting. A safe estimate would be twice the size of all your projects.

CPU

We recommend that you use 2 CPU or above. Response time of unicorn will increase for more number of CPUs. We recommend using: CPU cores + 1 = unicorn workers. So for a machine with 2 cores, 3 unicorn workers is ideal.

Memory

You need at least 2GB of addressable memory (RAM + swap) to install and use GlitterGallery!

Installation

1. Packages / Dependencies

Make sure your system is up-to-date:

sudo dnf update

Following are the dependencies of some of the gems we are using and a few tool you may need along the way.

sudo dnf install ruby-devel postgresql-server postgresql-contrib postgresql-devel cmake qt-webkit-devel ImageMagick ImageMagick-devel gnupg vim

The qmake executable is now called qmake-qt4. This will cause capybara-webkit installation to fail. So you need to add an environment variable your profile or the system profile.

export QMAKE=/usr/bin/qmake-qt4

2. Ruby

You can user version manager of your choice RVM, rbenv or chruby. We use rvm, here is the command to install rvm and latest stable version of ruby:

# Install mpapis public key
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
# Install rvm and ruby
\curl -sSL https://get.rvm.io | bash -s stable --ruby
# Reload shell
source /usr/local/rvm/scripts/rvm

3. System Users

Create git user which can be logged in without password.

 # Add user
 sudo adduser git
 # Remove password
 sudo passwd -d git

4. Postgres

Checkout Fedora Documentation of PostgreSQL. It covers all the configuration options and explains how you can work with SELinux. Following steps will get you started with minimum number of steps, however this may not be what you need. For example: You may want to keep SElinux enabled and have a user different from postgres.

# Disable SELinux
sudo vim /etc/selinux/config
# Change SELINUX option to permissive and restart system. Check your status with
/usr/sbin/getenforce


# Creates the configuration files postgresql.conf and pg_hba.conf
sudo postgresql-setup initdb
# Start postgres server
sudo systemctl start postgresql
# Configure access to your database server
sudo vim /var/lib/pgsql/data/pg_hba.conf
# Change method of line with Address as `127.0.0.1/32` to md5
host    all             all             127.0.0.1/32            md5
# Login to postgres shell
sudo -u postgres psql
# Set password for postgres user
postgres=# \password postgres

5. OpenSSH Server

You will need it to authenticate user keys when they push, pull, clone etc over ssh.

# install the OpenSSH
sudo dnf install openssh-server openssh-clients
# start the sshd daemon
systemctl start sshd.service

Refer to Starting an OpenSSH Server for further details.

6. Gitlab-shell

Gitlab-shell manages the SSH access for GG. Please don't use the original repo, use our fork instead.

# Clone the repo
git clone https://github.com/sonalkr132/gitlab-shell
# Copy and edit the configuration file
cd gitlab-shell
cp config.yml.example config.yml; vim config.yml

You will need to edit:

user: system user you created

gitlab_url: domain name

repos_path: directory you would like to use for storing your projects

auth_file: file which will store your user ssh keys

You will need to add a .gitlab_shell_secret file to the gitlab-shell repo.

# Make the file
touch .gitlab_shell_secret

# launch irb to create the secret tocken
irb
>> require 'securerandom'
=> true
>> SecureRandom.hex(64)
=> "3fe397575565365108556c3e5549f139e8078a8ec8fd2675a83de96289b30550a266ac04488d7086322efbe573738e7b3ae005b2e3d9afd718aa337fa5e329cf"
>> exit
# paste the code in the file
echo "3fe397575565365108556c3e5549f139e8078a8ec8fd2675a83de96289b30550a266ac04488d7086322efbe573738e7b3ae005b2e3d9afd718aa337fa5e329cf" >> .gitlab_shell_secret
# some setup files
cd; mkdir .ssh; chmod 700 .ssh
touch .ssh/authorized_keys; chmod 600 .ssh/authorized_keys

7.Nginx

(optional for development instance)

We recommend using Nginx for server. Refer to Fedora doc on Nginx for further config details.

# install it with
sudo dnf install nginx

Done!

Now you can clone our repo and install the gems

# clone the repo
git clone https://github.com/glittergallery/GlitterGallery/
# install bundler
gem install bundler
# move in the project and install the gems -j<number of CPUs +1>
cd GlitterGallery; bundle install -j4

Configuration files you need to edit

0_glitterconfig.rb

Copy the example file and edit it

cp config/initializers/0_glitterconfig.rb.example config/initializers/0_glitterconfig.rb; vim config/initializers/0_glitterconfig.rb

Options which may need changes:

Glitter::Application.config.shell_path: points to the gitlab-shell folder Glitter::Application.config.devise_mail: should be your email address Glitter::Application.config.repo_path: should be same as one you used in gitlab-shell (repos_path)

To set up email, you'll have to setup environment variables for the following variables (optional for development instance. Use Mail Catcher instead):

  • MAIL_ADDRESS
  • MAIL_PORT
  • MAIL_DOMAIN
  • MAIL_USERNAME
  • MAIL_PASSWORD
  • MAIL_AUTHENTICATION

For gmail, these would be

  • MAIL_ADDRESS = smtp.gmail.com
  • MAIL_PORT = 587
  • MAIL_DOMAIN = gmail.com
  • MAIL_USERNAME = yourgmailid@gmail.com
  • MAIL_PASSWORD = yourgmailpassword
  • MAIL_AUTHENTICATION = plain

database.yml

Copy the example file and edit it

cp config/database.yml.example config/database.yml; vim config/database.yml

Options which may need changes:

  • username: postgres user which has access to the database you would like to use
  • password: password of your postgres user
  • database: name of the database you would like to use

secret.yml

Generate the random hex code as explained previously or you can use rake secret

# generate key
rake secret

Use separate keys for secret_key_base and devise_secret_key.

You are all set to start the unicorn server.

# create and migrate database 
rake db:create db:migrate
# generate assets
RAILS_ENV=production rake assets:precompile
# start server
bundle exec unicorn -E production -c config/unicorn.rb -D

This will start the unicorn server in daemon mode. To stop the Unicorn master process use

kill -QUIT `cat tmp/unicorn.pid`

If you just want to launch a development instance and do not plan on using push over ssh/http then rails default server should work fine. You can start it with rails s.

Delayed Jobs

We use Delayed Job to execute longer tasks in background. You can start working off jobs with: Rake jobs:work

Mailcatcher

In development environment, Mailcatcher will handle the sending of emails for you. You can set it up with following:

  • Execute: gem install mailcatcher
  • Don't add it to gemfile. just run mailcatcher to start it.
  • Go to "127.0.0.1:1080" to see the mails.

Social Authentication

You can choose which providers you want to enable in config/initializers/0_glitterconfig.rb. For example if you only want Facebook and Github, you'd change

Glitter::Application.config.auth_methods=[:facebook,:twitter,:open_id,:linkedIn,:github]

to

Glitter::Application.config.auth_methods=[:facebook,:github]

For every auth provider that you enable, you'll have to set the respective key and secret in the environment variables. For facebook, that would be FACEBOOK_KEY and FACEBOOK_SECRET