BitNami GitLab

     

    IMPORTANT: It is necessary to enable SSH server to be able to pull your code into the application. The SSH server is disabled by default in the BitNami GitLab Virtual Machine. Check this guide to know how to enable it.

    gitlab.png

    GitLab allows you to keep your code secure on your own server, manage repositories, users and access permissions, communicate through issues, line-commens, wiki pages and perform code reviw with merge requests. It is powered by Ruby on Rails and completely free and open source (MIT license).

    Please, take a look to the Quick Start Guide to know the basic use of this Stack.

    How to log in the GitLab application?

    The default credentials for the GitLab application are:

    user mail: user@example.com
    password: bitnami1 (bitnami, for versions of BitNami GitLab > 6.4.x)
    

    It is advisable to use a Hostname instead of and IP address. In the Virtual Machines and AMIs exist a tool for changing it automatically. Do not use "git." in your hostname, this cause problems if you want to access through http. You only have to run the following command to change it:

    $ sudo /opt/bitnami/apps/gitlab/bnconfig --machine_hostname example.com
    

    If you have configured GitLab to use an static domain name, you should remove or rename the "/opt/bitnami/apps/gitlab/bnconfig" to disable it. You can also add the domain in the /etc/hosts file so gitlab-shell will use 127.0.0.1 to push the changes in the repository:

    127.0.0.1    example.com

     

    If you want, you can configure it manually. These are the configuration options that you should modify in the "/opt/bitnami/apps/gitlab/htdocs/config/gitlab.yml" file:

    host: YOUR_DOMAIN
    

    In previous versions (GitLab 4.x) it is also necessary to change the following parameter:

    ssh_host: YOUR_DOMAIN
    

    Then restart Apache server:

    $ installdir/ctlscript.sh restart apache
    

    How to push your changes to the GitLab application?

    Once you have uploaded your private key to Gitlab, you can upload your repository to the application. These are the basic steps:

    git config --global user.name "Your full name"
    git config --global user.email "user@example.com"
    
    git checkout master
    git remote add origin git@YOUR_HOSTNAME:test/test.git
    git push -u origin master
    

    Virtual Machines have SSH server disabled by default. That it is necessary to sync your changes with GitLab. You can see how to enable it at /Virtual_Appliances_Quick_Start_Guide#How_to_enable_sshd.3f

    How to start/stop the servers?

    You can use the "ctlscript.sh" utility from the command line. This script is in the installation directory.

    $ cd installdir
    $ ./ctlscript.sh start
    

    This command start alls the required servers: Apache, MySQL, Redis and the GitLab Sidekiq server.

    How to change the default URL to the root?

    There are a few files you have to modify in order to remove the "/gitlab" url to the root url. You can find below a configuration example. You must start modifying both "installdir/apps/gitlab/conf/httpd-app.conf" and "installdir/apps/gitlab/conf/httpd-prefix.conf" files with this new content (installdir must be replaced with the actual path of the installation; your_hostname and your_apache_port must be changed too):

    /installdir/apps/gitlab/conf/httpd-app.conf:

    <Directory "/installdir/apps/gitlab/htdocs/public">
        Options -MultiViews
        <IfVersion < 2.3 >
        Order allow,deny
        Allow from all
        </IfVersion>
        <IfVersion >= 2.3>
        Require all granted
        </IfVersion>
    </Directory>
    PassengerPreStart http://<your_hostname>:<your_apache_port>/
    

    /installdir/apps/gitlab/conf/httpd-prefix.conf:

    DocumentRoot /installdir/apps/gitlab/htdocs/public
     
    The /installdir/apps/gitlab/htdocs/app/assets/javascripts/api.js.coffee file has to be modifed too, changing these three lines:
      users_path: "/gitlab/api/:version/users.json"
      user_path: "/gitlab/api/:version/users/:id.json"
      notes_path: "/gitlab/api/:version/projects/:id/notes.json"

    to

      users_path: "/api/:version/users.json"
      user_path: "/api/:version/users/:id.json"
      notes_path: "/api/:version/projects/:id/notes.json" 

    Finally, the file installdir/apps/gitlab/htdocs/config/gitlab.yml needs to be change by disabling this option:

      relative_url_root: /gitlab

    to

      #relative_url_root: /gitlab

    It is also necessary to recompile the assets to work with the new URL:

    $ cd installdir/apps/gitlab/htdocs
    $ bundle exec bin/rake assets:precompile 

    GitLab-shell configuration has to be updated too. It is located at the file <installdir>/apps/gitlab/gitlab-shell/config.yml:

    gitlab_url: "http://<your_hostname>:<your_apache_port>/"

    Finally, restart the Apache server and access to your BitNami GitLab installation through:

    http://<your_hostname>:<your_apache_port>/

    How to create a full backup of GitLab?

    Because BitNami stacks are self-contained, the simplest option for performing your backups is to copy or compress the BitNami Stack installation directory. To do so in a safe manner, you will need to stop all servers, so this method may not be appropriate if you have people accessing the application continously.

    linux_platform.pngOn Virtual Machines and Cloud Images:

    sudo /opt/bitnami/ctlscript.sh stop

    mac_platform.png

    On OS X:

    $ cd installdir
    $ ./ctlscript.sh stop
    $ cp -r installdir application-backup
    

    Or you can create a tarball:

    $ tar -czvf application-backup.tar.gz installdir
    

    Or a zip file:

    $ zip -r application-backup.zip installdir/*

    To restore this backup you only need to uncompress the backup in the same location. It is important to use the same path that was used when the stack was originally installed.

    For example if you have a backup in a Red Hat machine, you can copy it to an Ubuntu Linux machine (a different distro!) in the same location. Then start the servers and that’s all.

    On Virtual Machines and Cloud Images:

    $ sudo /opt/bitnami/ctlscript.sh start

    On OS X:

    $ cd installdir
    $ ./ctlscript.sh start
    

    You just need to be carefull to keep the same permissions for the files and folders. If you installed as root make sure that in the new machine you copy the files also as root. And this case, if you are also moving MySQL or PostgreSQL, you will need to create those users in the new machine (if they don't exist yet).

    win_platform.png On Windows you should follow the same process. Stop the servers using the shortcuts and copy the whole installation directory. To restore the system, copy the directory to a different Windows machine in the same location and follow these steps from a command prompt:

    $ cd installdir
    $ serviceinstall.bat INSTALL
    

    You can access your BitNami Application at the usual URL.

    If you want to create only a database backup, check the following link for MySQL /Components/MySQL#How_to_create_a_database_backup or for PostgreSQL /Components/PostgreSQL#How_to_create_a_database_backup.3f

    You should also create a backup of the /home/git folder where are stored the repositories.

    How to run rake commands?

    To run rake commands you have to use the rake script located inside installdir/apps/gitlab/htdocs/bin.

    First load the Bitnami environment 

    sudo installdir/use_gitlab

    Then go to htdocs folder: 

    cd installdir/apps/gitlab/htdocs

    and run the command like this:

    ruby bin/rake rake_command  

     

    How to configure the email settings of GitLab?

    You can configure the SMTP settings during the installation process. If you are using the Virtual Machine or AMI, you can configure it manually. For example, these are the options to configure it using a GMail account:


    /opt/bitnami/apps/gitlab/htdocs/config/environments/production.rb

    config.action_mailer.raise_delivery_errors = true
    config.action_mailer.delivery_method = :smtp   
    config.action_mailer.perform_deliveries = true
    config.action_mailer.smtp_settings = {
    :address => "smtp.gmail.com",
    :port => 587,
    :domain => "gmail.com",
    :authentication => :plain,
    :user_name => "your_account@gmail.com",
    :password => "your_password",
    :enable_starttls_auto => true 
    } 
    

    Then restart Sidekiq and Apache servers:

    $ sudo /opt/bitnami/ctlscript.sh restart gitlab_sidekiq
    $ sudo /opt/bitnami/ctlscript.sh restart apache
    

    How to upgrade Gitlab?

    General procedure to upgrade the stack

    Remember that all the paths in this guide are for Virtual Machines and Cloud Images. If you are using Gitlab stack, you have to change the path /opt/bitnami for your installation path.

    It is strongly recommended that you create a backup before starting the update process. If you have important data, it is advisable that you create and try to restore a backup to ensure that everything works properly.

    There are two different ways to upgrade your application.

    1. If you want to upgrade the application and all Stack components PHP, Ruby, MySQL, Apache… You can follow the steps described at How to upgrade the full Stack migrating the data?
    2. In case you only want to upgrade the application code without modifying any other Stack components,  you should follow the guide which is in the application page itself.

    In the Gitlab case, these are the steps to migrate the database from an old version to a new one:

    • First of all, backup the gitlab, gitlab_ci databases and the .ssh file in git and gitlab_ci directories.
        cd /opt/bitnami
        sudo ./use_gitlab
        /opt/bitnami/mysql/bin/mysqldump -u root -p bitnami_gitlab > bitnami_gitlab_bk.sql
        /opt/bitnami/mysql/bin/mysqldump -u root -p bitnami_gitlabci > bitnami_gitlabci_bk.sql
        cp -r /home/git/.ssh PATH_TO_BACKUP/git/.ssh
        cp -r /home/gitlab_ci/.ssh PATH_TO_BACKUP/gitlab_ci/.ssh
    

    Important: If you are using Gitlab stack in the same machine, you have now to stop the old version and remove the gitlab users.

        /opt/gitlab_old_version/ctlscript.sh stop
        deluser git
        rm -r /home/git
        deluser gitlab_ci
        rm -r /home/gitlab_ci
    
    • Start the new Gitlab version.
    • Copy the repositories and .ssh backups to the new version server.
    • Stop all servers and start only MySQL. Note that the installation directory could be different.
        sudo /opt/bitnami/ctlscript.sh stop
        sudo /opt/bitnami/ctlscript.sh start mysql      
    
    • Now remove the databases and add the old ones.
        sudo /opt/bitnami/use_gitlab
        mysql -u root -p 
        INSERT YOUR PASSWORD HERE
        drop database bitnami_gitlab;
        create database bitnami_gitlab;
        grant all privileges on bitnami_gitlab.* to 'bitnami'@'localhost' identified by 'password';
        grant all privileges on bitnami_gitlab.* to 'gitlab'@'localhost' identified by 'password';    
        flush privileges;
        drop database bitnami_gitlabci;
        create database bitnami_gitlabci;
        grant all privileges on bitnami_gitlabci.* to 'bitnami'@'localhost' identified by 'password';
        grant all privileges on bitnami_gitlab.* to 'gitlab'@'localhost' identified by 'password';    
        flush privileges; 
        \q
        
        mysql -u root -p bitnami_gitlab < PATH_TO_BACKUP/bitnami_gitlab_bk.sql
        mysql -u root -p bitnami_gitlabci < PATH_TO_BACKUP/bitnami_gitlabci_bk.sql    
    
    • Update configuration files in the new version so that they correspond to the old version ones. At least you have to update database.yml files, so open them with a text editor and modify the password fields with the password provided to the database in the previous step. There will be two database.yml files.
        /opt/bitnami/apps/gitlab/htdocs/config/database.yml
        /opt/bitnami/apps/gitlabci/htdocs/config/database.yml
    
    • Copy the .ssh backup files to the new server
        cp -r PATH_TO_BACKUP/git/.ssh /home/git/.ssh
        cp -r PATH_TO_BACKUP/gitlab_ci/.ssh /home/gitlab_ci/.ssh
    • Now run the following command:
        cd /opt/bitnami/apps/gitlab/htdocs
        bundle install --deployment --without development test sqlite postgres --binstubs
    
        sudo su git
        ruby bin/rake db:migrate RAILS_ENV=production
        exit
    
    • Now fix the dashboard
        cd /opt/gitlab/apps/gitlab/htdocs
        ruby bin/rake migrate_iids RAILS_ENV=production 
    
    • Then restart services:
        /opt/bitnami/ctlscript.sh restart
    
    Keeping in sync with the GitLab repository at GitHub
    Since the GitLab application is changing very fast, BitNami GitLab stack is including the .git files necessaries to be synched with the repository.
     
    This is an advanced feature that should be used only by someone that knows the application and what is happening at every step of the process described below.
     
    backup of the application directory should be done before moving forward.
     
    As some configuration parameters are adjusted during the installation, there will be some differences between the installed version and the repository even if the installer was built recently.
     
    To synch GitLab with its repository at GitHub, the steps below must be followed. 
    cd /opt/bitnami
    ./ctlscript.sh stop gitlab_sidekiq
    cd apps/gitlab/htdocs
    su git
     
    BitNami modifies both Gemfile and Gemfile.lock files file in order to allow an offline installation. You should check them out and run bundle install after the "git checkout":
    git checkout Gemfile*
    git fetch
    git checkout <brach> (where <branch> is, for instance, master or 5-2-stable)
    
     
    Now log in as root user or use "sudo" to run the following command:
    bundle install --deployment --without development test sqlite postgres --binstubs
     
    Again, log in as "git" user and update the database. It should be necessary to update any change in the database:
    su git
    ruby bin/rake db:migrate RAILS_ENV=production 

    Then restart services:

    /opt/bitnami/ctlscript.sh start gitlab_sidekiq
    /opt/bitnami/ctlscript.sh restart apache

    Now, the GitLab application shipped at the BitNami stack, AMI or Virtual Machine is up to date.

    Troubleshooting

    Charlock_holmes gem requires a modification in the Ruby config.h file. If you find problems compiling it, add the following entry in the "/opt/bitnami/ruby/includes/ruby-1.9.1/x86_64-linux/ruby/config.h" file:

    #define HAVE_EACCESS 1
    

    How to edit and commit files from the GitLab application?

    GitLab web application allows you edit a file and commit the changes into the repository. To enable this feature it is necessary to create the "satellites" repositories. If you check the production.log file you can see an error similar to this: "RuntimeError: Satellite doesn't exist"

    To create them you can run the following command after creating a project:

    $ sudo su gitlab
    $ cd installdir/apps/gitlab/htdocs
    $ bundle exec bin/rake gitlab:satellites:create RAILS_ENV=production
    


    Now you can edit & commit changes into the repository from the GitLab application itself.

    How to debug GitLab errors?

    The GitLab log files are saved in /opt/bitnami/apps/gitlab/htdocs/logs folder. The main log file is production.log.

    Once Apache starts, it will create two log files, the access_log and the error_log /installdir/apache2/logs directory or in /var/log/httpd if you are using Amazon Linux or Red Hat Enterprise cloud images.

    In Virtual Machines, Cloud Images and Ubuntu based Bitnami Cloud Hosting images installdir is /opt/bitnami.

    The access_log file is used to track client requests. When a client requests a document from the server, Apache records several parameters associated with the request in this file, such as: the IP address of the client, the document requested, the HTTP status code, and the current time.

    The error_log file is used to record important events. This file includes error messages, startup messages, and any other significant events in the life cycle of the server. This is the first place to look when you run into a problem when using Apache.

    If no error is found, you will see a message similar to:

    Syntax OK
    /installdir/ctlscript.sh : httpd started
    

    The main MySQL log file is created at /installdir/mysql/data/mysqld.log file.

    GitLab servers write the log files into the "/installdir/apps/gitlab/htdocs/logs" folder. Check these log files if Sidekiq server can not be started.

    How to use GitLab CI integrated with GitLab (> 5.4 with GitLab CI 3.0.0)?

    IMPORTANT: For this integration, the domain name of the machine is set in the configuration files of the repositories that are cloned internally. Because of that, if the domain of the machine change, GitLab and GitLab CI will continue working automatically in BitNami AMI and Virtual Machines but the internal clone of the repositories will fail. Also, the necessary information for the integration of each project will be out of date too. To fix it, these steps must be repeated for all existing projects.
    BitNami GitLab stack also ships GitLab CI. GitLab CI can be selected during the installation of BitNami GitLab stack and it is installed by default on BitNami GitLab cloud images and virtual machines.

    gitlabplusgitlabci.png

    • GitLab will be accessible at "http://<hostname_gitlab_server>:<apache_port>/gitlab"
    • GitLab CI will be accessible at "http://<hostname_gitlab_server>:<apache_port>/gitlabci"

    GitLab and GitLab CI have been designed to work jointly, so, when a commit is done on a GitLab project, for instance, GitLab CI is able to detect it and run any defined task. An example of this configuration is described below.

    1. Add a project on GitLab.

    projectongitlab.png

    1. Add the same project on GitLab CI. To do so, go to GitLab CI (http://example.com/gitlabci) and log in. Then press on GitLab Projects and click on the Add button of the proper project.

    gitlabprojects-on-gitlabci.png

    1. Add a runner to the new project. Go to the Runners menu inside the project created and click on Add the existing runner to the current project.

    gitlabci-runner-to-project-2.png

    1. Enable the service "GitLab CI" on the project at GitLab. On GitLab CI, go to the menu Integration of the current project and copy the token and the url. Now go to GitLab. On the same project, go to services. Add the copied information, tick to activate the service and press both Save and Test settings. A green circle will appear if everything is correct.

    gitlabci-enabled-at-gitlab.png

    1. The integration is completed! Also a first build will start automatically at GitLab CI.

    gitlabci-working-with-gitlab.png

    How to use GitLab CI integrated with GitLab (GitLab < 5.4 with GitLab CI 2.2.0)?

    BitNami GitLab stack also ships GitLab CI. GitLab CI can be selected during the installation of BitNami GitLab stack and it is installed by default on BitNami GitLab cloud images and virtual machines.

    gitlabplusgitlabci.png

    • GitLab will be accessible at "http://<hostname_gitlab_server>:<apache_port>/gitlab"
    • GitLab CI will be accessible at "http://<hostname_gitlab_server>:<apache_port>/gitlabci"

    GitLab and GitLab CI have been designed to work jointly, so, when a commit is done on a GitLab project, for instance, GitLab CI is able to detect it and run any defined task. An example of this configuration is described below.

    1. Add a project on GitLab.

    projectongitlab.png

    1. Create a ssh key for gitlab_ci user in this machine without a password. This key will allow GitLab CI to have read access to any chosen repository:
    sudo su gitlab_ci -c "ssh-keygen -t rsa"
    
    1. Add this key in "Deploy Keys" on the GitLab project. On GitLab, go to Projects -> BitNami sample project -> Settings -> Deploy Keys -> Add deploy key, paste the key generated before and save it with any name.

    gitlabdeploykey2.png

    1. On your client (if it is different from the server you are using to host the GitLab server), start the repository as it is described at GitLab. This step is not related to the integration with GitLab CI but the repository should be started to complete the integration. Add your personal key in My profile -> SSH Keys and run the following commands for a new repository:
    mkdir bitnami-sample-project
    cd bitnami-sample-project
    git init
    touch README
    git add README
    git commit -m 'first commit'
    git remote add origin git@<hostname_gitlab_server>:bitnami-sample-project.git
    git push -u origin master
    1. Clone the repository with the gitlab_ci user on the GitLab server.
    sudo su gitlab_ci -c "mkdir /opt/bitnami/apps/gitlabci/repositories"
    sudo su gitlab_ci -c "/opt/bitnami/git/bin/git config --global user.name 'Administrator'"
    sudo su gitlab_ci -c "/opt/bitnami/git/bin/git config --global user.email 'user@example.com'"
    sudo su gitlab_ci -c "cd /opt/bitnami/apps/gitlabci/repositories/ && /opt/bitnami/git/bin/git clone git@<hostname_gitlab_server>:bitnami-sample-project.git"
    Cloning into 'bitnami-sample-project'...
    remote: Counting objects: 3, done.
    Receiving objects: 100% (3/3), 201 bytes, done.
    remote: Total 3 (delta 0), reused 0 (delta 0)
    1. Create the project on GitLab CI by pressing 'Add project' on the GitLab CI application. Add the parameters described below and save it.

    gitlabciproject.png

    1. Name: bitnami-sample-project
    2. Token: (blank)
    3. Path: /opt/bitnami/apps/gitlabci/repositories/bitnami-sample-project
    4. Follow branches: master
    5. Scripts: ls
    1. Once created, press on "Details". "Project URL" and "Project Token" are required for the next step.

    importantvaluesgitlabci.png

    1. Enable GitLab CI on the repository created on GitLab. To do so, go to GitLab -> Projects -> BitNami sample project -> Settings -> Services -> GitLab CI. Select "Active" and fill "Project URL" and "Project Token" with the values at the previous step. Finally, press "Save".

    placeimportantvaluesfromgitlabci.png

    1. GitLab integration with GitLab CI is complete! It can be tested by commiting a new file (for instance) from your client (if it is different from the server you are using to host the GitLab server). Then, GitLab CI will show the following:

    successfullyintegrated2.png

    Troubleshooting

    GitLab error:

    http.rb:763:in `initialize': getaddrinfo: Temporary failure in name resolution (SocketError)

    Check the domain name returns the correct IP address. You can also add the domain name in the /etc/hosts file so gitlab-shell will resolve the domain to 127.0.0.1.

    127.0.0.1     example.com
    Tag page (Edit tags)
    • No tags
    Page statistics
    107101 view(s), 65 edit(s) and 28147 character(s)

    Comments

    You must login to post a comment.

    Attach file

    Attachments

    FileSizeDateAttached by 
     gitlab.png
    GitLab stack
    10.57 kB16:02, 14 Mar 2013AdminActions
     gitlabci-enabled-at-gitlab.png
    GitLab CI service enable at GitLab
    53.77 kB09:13, 24 Jul 2013VictorActions
     gitlabci-runner-to-project-2.png
    GitLab CI runner added to a project
    57.2 kB09:19, 24 Jul 2013VictorActions
    gitlabci-runner-to-project.png
    GitLab CI runner added to a project
    57.07 kB09:17, 24 Jul 2013VictorActions
     gitlabci-working-with-gitlab.png
    GitLab CI building GitLab projects!
    32.8 kB09:15, 24 Jul 2013VictorActions
     gitlabciproject.png
    Create a new GitLab CI project
    71.83 kB14:35, 10 May 2013VictorActions
    gitlabdeploykey.png
    Adding a deploy key to a GitLab project
    49.11 kB14:05, 10 May 2013VictorActions
     gitlabdeploykey2.png
    Adding a deploy key to a GitLab project
    49.11 kB14:08, 10 May 2013VictorActions
     gitlabplusgitlabci.png
    GitLab CI is included in BitNami GitLab stack installer
    20.8 kB13:23, 10 May 2013VictorActions
     gitlabprojects-on-gitlabci.png
    GitLab projects on GitLab CI
    34.92 kB09:06, 24 Jul 2013VictorActions
     importantvaluesgitlabci.png
    Important values from GitLab CI project
    45.4 kB14:47, 10 May 2013VictorActions
     placeimportantvaluesfromgitlabci.png
    Set GitLab CI values on GitLab
    50.84 kB14:48, 10 May 2013VictorActions
     projectongitlab.png
    Sample project created on GitLab
    38.84 kB13:36, 10 May 2013VictorActions
     successfullyintegrated1.png
    Successfully integrated (1)
    33.58 kB14:58, 10 May 2013VictorActions
     successfullyintegrated2.png
    Successfully integrated (2)
    105.17 kB14:58, 10 May 2013VictorActions