---
title: Setting up GitLab on Scaleway Instances with a Managed Database for PostgreSQL
description: This page shows you how set up GitLab with a managed PostgreSQL database
tags: GitLab PostgreSQL-database
  - instances
  - postgresql-and-mysql
dates:
  validation: 2025-02-24
  posted: 2019-11-08
  validation_frequency: 12
difficulty: beginner
usecase:
  - application-hosting
ecosystem:
  - third-party
---
import image from './assets/scaleway-gitlab_dashboard.webp'

import Requirements from '@macros/iam/requirements.mdx'


GitLab serves as an open-core Git repository manager, offering a broad suite of features such as a wiki, issue tracking, and CI/CD pipelines. In the open-core model, the fundamental software functionalities are available under an open-source license, complemented by optional modules.

Numerous major technology companies rely on GitLab to oversee their software development life cycles. Originally crafted in Ruby, the platform now incorporates Go and Vue.js within its technology stack.
For those seeking a dependable and high-performance hosting solution, Scaleway Development Instances present an ideal choice for your GitLab infrastructure. They provide a robust infrastructure for hosting your GitLab Instance, coupled with a Managed Database for PostgreSQL.

<Message type="tip">
  We recommend you follow this tutorial using a [General Purpose Instance](/instances/reference-content/general-purpose/).
</Message>

<Requirements />

- A Scaleway account logged into the [console](https://console.scaleway.com)
- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization
- An [SSH key](/organizations-and-projects/how-to/create-ssh-key/)
- An [Instance](/instances/how-to/create-an-instance/) running Ubuntu Jammy Jellyfish (22.04 LTS)
- A domain or subdomain configured to point to the IP address of your Instance
- [Enabled the SMTP ports](/instances/how-to/send-emails-from-your-instance/) to send emails from your Instance

## Installing GitLab

1. Connect to your Instance using [SSH](/instances/how-to/connect-to-instance/)
    ```
    ssh root@<your_instance_ip>
    ```
2. Update the `apt` package 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 your domain name in the `EXTERNAL_URL` variable, then install GitLab using `apt`:
    ```
    EXTERNAL_URL="https://gitlab.example.com" apt install -y gitlab-ce
    ```

    <Message type="important">
      GitLab will automatically request a [Let's Encrypt](/tutorials/configure-nginx-lets-encrypt/) certificate for your domain name. Make sure you have pointed the `A-Record` of your domain to your Instance's IP address to be able to obtain a valid certificate.
    </Message>

## Creating a Database

1. [Create a Managed PostgreSQL Database Instance](/managed-databases-for-postgresql-and-mysql/how-to/create-a-database/) from the Scaleway console. You are taken to your Database's **Overview** page.
2. Click the **Users** tab, then on **Add User**.
3. Enter the username (`gitlab`) and a secure password. In the permission tab, give `ALL` permissions for the user on the `rdb` database.
4. Retrieve the Database Instance **Endpoint** from the **Overview** tab, as it is required for the following steps. The first part, before the colon, is the IP address, and the second part is the port.

## Configuring the GitLab Database

For the following steps, you should be connected to the Ubuntu Bionic Beaver Instance on which you installed GitLab.

1. Open the file `/etc/gitlab/gitlab.rb` in your favorite text editor (For example `nano` or `vim`).
2. Add the following parameters to the GitLab configuration file:
    ```
    # Disable the built-in Postgres server
    postgresql['enable'] = false

    # Connection details of the Scaleway Database
    gitlab_rails['db_adapter'] = 'postgresql'
    gitlab_rails['db_encoding'] = 'utf8'
    gitlab_rails['db_database'] = '<SCALEWAY_DATABASE_NAME>'
    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 Database. In our example, this is `gitlab_production`
    - `<SCALEWAY_DATABASE_IP>`: The IP address of your Scaleway Database Instance
    - `<SCALEWAY_DATABASE_PORT>`: The port of your Scaleway Database Instance
    - `<SCALEWAY_DATABASE_USERNAME>`: Your Scaleway Database user
    - `<SCALEWAY_DATABASE_PASSWORD>`: Password of your Scaleway Database user
3. Once modified save the file and exit the text editor.
4. Reconfigure GitLab:
    ```
    gitlab-ctl reconfigure
    ```
5. Create and seed the GitLab database:
    <Message type="important">
      This command overwrites your GitLab database. Be careful when using it. You will lose any previous data stored in the database.
    </Message>

    ```
    gitlab-rake gitlab:setup
    ```
6. Confirm the database seed by typing `yes` when prompted.

## Logging into GitLab

1. Set the password for your root user with the following command:
    ```bash
    gitlab:password:reset[root]
    ```

    Enter and confirm the password when prompted.
2. Open your web browser and go to the URL you configured for GitLab (for example: `https://gitlab.example.com`)
3. Log in using the user `root` and the password you defined in step 1.

    The GitLab dashboard displays. You can now configure your GitLab installation, and add users and repositories. All data is stored securely on your Scaleway Database Instance:
    <Lightbox image={image} alt="" />

For more information on how to configure GitLab, refer to the official [documentation](https://docs.gitlab.com/ee/administration/index.html#configuring-gitlab).