Setting up Gitlab with a Scaleway Elements managed Database

Gitlab - Overview

GitLab is an open-core Git-repository manager providing a Wiki, Issue-Tracking and CI/CD pipeline features. Open-core means that the core functionalities of the software are released under an open-source licence with added optional modules. The tool is used by many large technology companies to manage their software development life cycle. The tool was initially developed in Ruby and uses in the current technology stack also Go and Vue.js.

Requirements:

  • You have an account and are logged into console.scaleway.com You have configured your SSH Key
  • You have a Virtual Cloud Instance or Bare Metal Server running on Ubuntu Bionic Beaver (18.04)
  • You have a domain or subdomain configured to point to the IP address of your Instance
  • You have enabled the SMTP ports to be able to send emails from your Instance

Installing GitLab

1 . Connect yourself to your instance using SSH

ssh root@<your_instance_ip>

2 . Update the apt packet cache and upgrade the software already installed on the instance:

apt update && apt upgrade -y

3 . Install the following packages using apt:

apt install -y curl ca-certificates postfix

4 . Add the GitLab package repository and prepare the installation of GitLab Community Edition by running the script:

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | bash

5 . Set configure your domain name in the EXTERNAL_URL variable, then install GitLab using apt:

EXTERNAL_URL="https://gitlab.example.com" apt install -y gitlab-ce

Important: GitLab will automatically request a Let’s Encrypt certifcate for your domain name. Make sure you have pointed the A-Record of your domain to your instances IP address to be able to obtain a valid certificate.

Configuring the GitLab Database

To configure GitLab with your Scaleway Elements Datatabase Instance, you need to configure the database from your Console in a first step:

  • Enter the Database section and click on your Database Instance
  • Click on the Databases tab, then on Create Database.
  • Enter the database name (gitlab_production) and confirm by clicking on Create Database.
  • Click on the Users tab, then on Add User.
  • Enter the username (gitlab) and a secure password. In the permission tab give ALL permissions for the user on the gitlab_production database.
  • Retrieve the database instance IP address and Port as they will be required for the following steps:

1 . Open the file /etc/gitlab/gitlab.rb in your favourite text editor (For example nano or vim).

2 . Add the following parameters in the Gitlab configuration file:

# Disable the built-in Postgres server
postgresql['enable'] = false

# Connection details of the Scaleway Elements Database
gitlab_rails['db_adapter'] = 'postgresql'
gitlab_rails['db_encoding'] = 'utf8'
gitlab_rails['db_database'] = '<SCALEWAY_DATABASE_BASE>'
gitlab_rails['db_host'] = '<SCALEWAY_DATABASE_IP>'
gitlab_rails['db_port'] = '<SCALEWAY_DATABASE_PORT>'
gitlab_rails['db_username'] = '<SCALEWAY_DATABASE_USERNAME>'
gitlab_rails['db_password'] = '<SCALEWAY_DATABASE_PASSWORD>'

Replace the following values in the configuration:

  • <SCALEWAY_DATABASE_BASE>: The name of your Scaleway Elements Database. It is recommended to use a name like gitlab_production
  • <SCALEWAY_DATABASE_IP>: The IP address of your Scaleway Elements Database Instance
  • <SCALEWAY_DATABASE_PORT>: The port of your Scaleway Elements Database Instance
  • <SCALEWAY_DATABASE_USERNAME>: Your Scaleway Elements Database user
  • <SCALEWAY_DATABASE_PASSWORD>: Password of your Scaleway Elements Database user

3 . Once modified save the file and exit the text editor.

4 . Reconfigure GitLab:

gitlab-ctl reconfigure

5 . Seed the GitLab database:

Important: This command overwrites your GitLab database. Be carefully when using it. You will lose any previous data stored in the database.

DISABLE_DATABASE_ENVIRONMENT_CHECK=1 gitlab-rake gitlab:setup

Confirm the database seed by typing yes when prompted.

Logging into GitLab

1 . Open your web browser and go to your Gitlab URL (for example: https://gitlab.example.com)

2 . Configure a password for your first user.

3 . Login using the user root and the password you have defined previously.

4 . The GitLab Dashboard displays. You can now configure your GitLab installation, add additional users and repositories. All data is stored securely on your Scaleway Elements Database Instance:

For more information how to configure GitLab, refer to the official documentation.

Discover a New Cloud Experience

Deploy SSD Cloud Servers in seconds.