Skip to content

Documenting Docker install method switching to two connections

What does this MR do and why?

Addressing: #387906 (closed)

In Milestone %16.0 we are switching GitLab instances by default to two connections (main, ci) to the same database. With this MR, we are documenting how customers can opt-in early for this feature for Docker Installation Method.

How to set up and validate locally

You can validate on any machine that has docker installed. I recommend using Linux machine, for example on GCP.

export GITLAB_HOME=$HOME/gitlab
sudo docker run --detach \
  --hostname docker_gitlab \
  --publish 443:443 --publish 80:80 \
  --name gitlab \
  --volume $GITLAB_HOME/config:/etc/gitlab \
  --volume $GITLAB_HOME/logs:/var/log/gitlab \
  --volume $GITLAB_HOME/data:/var/opt/gitlab \
  --shm-size 256m \
  gitlab/gitlab-ee:latest

It might take some time to be ready. By default the generated config/database.yml will only contain main. To validate:

docker exec gitlab cat /var/opt/gitlab/gitlab-rails/etc/database.yml

Switching to two connections

Edit the gitlab.rb file

sudo docker exec -it gitlab editor /etc/gitlab/gitlab.rb

Add/uncomment these lines

gitlab_rails['databases']['ci']['enable'] = true
gitlab_rails['databases']['ci']['db_database'] = 'gitlabhq_production'
gitlab_rails['databases']['ci']['database_tasks'] = false

Restart the container

sudo docker restart gitlab
docker exec gitlab cat /var/opt/gitlab/gitlab-rails/etc/database.yml

Now you should see both main and ci in the config/database.yml file

docker exec gitlab cat /var/opt/gitlab/gitlab-rails/etc/database.yml
  main:
    adapter: postgresql
    encoding: unicode
    collation: 
    database: gitlabhq_production
    username: "gitlab"
    password: 
    host: "/var/opt/gitlab/postgresql"
    port: 5432
    database_tasks: true
  ..... 
  ci:
    adapter: postgresql
    encoding: unicode
    collation: 
    database: gitlabhq_production
    username: "gitlab"
    password: 
    host: "/var/opt/gitlab/postgresql"
    port: 5432
    socket: 
    sslmode: 
    sslcompression: 0
    sslrootcert: 
    sslca: 
    load_balancing: {"hosts":[]}
    prepared_statements: false
    database_tasks: false

with ci pointing to the same database, and database_tasks: false

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #387906 (closed)

Merge request reports

Loading