5 posts tagged


Mar 25, 2020, 8:51

The Gitlab pecularities

For a very long time, I used to work with Jenkins most of my work time, but since my new job, I have to spend more time with Gitlab and started having a bunch of  WTFs. So here is my list:

  1. Caching. Distributed cache requires S3 implementation. Here is free one: https://min.io/
  2. Stages. Stages are not the same stages as Jenkins has, these are naturally separate jobs with the separate BUILD_IDs, so you'd better use CI_PIPELINE_ID.
  3. Declarative pipeline. The only YAML can be used with its pros and cons, but having Gitlab Actions is mainstream nowadays.
  4. Files. You can't store ssh key as a file in GitLab, only like a variable. That means you need to create one using echo $variable in your script. With proper permissions.

That seems to be a peculiarity of the Gitlab because of its nature.

The thing is that local cache is really local to the particular runner, so if you use shared runners each next task will be assigned most probably to the different runner(node). In this way you will not have the same cache unless you're using distributed cache stored on S3.

The easiest way to tackle this is to use a tag for each of your stage. Thus it's going to stick to particular runner.


For me worked following configuration for jwilder/nginx-proxy container.

  image: 'gitlab/gitlab-ce:latest'
  hostname: 'gitlab.it-expert.com.ua'
      external_url 'https://gitlab.it-expert.com.ua'
      registry_external_url 'https://registry.it-expert.com.ua'
    VIRTUAL_HOST: gitlab.it-expert.com.ua,registry.it-expert.com.ua
    VIRTUAL_PROTO: https
    - './data/config:/etc/gitlab'
    - './data/logs:/var/log/gitlab'
    - './data/data:/var/opt/gitlab'

Tricky part was to figure out how containers is connected and which and who should process SSL.

For this configuration you should supply SSL certificates both for nginx-proxy and gitlab-ce containers, because communications between them is also using SSL. For gitlab-ce use ./data/config/ssl folder.

Правильно указывать в docker-compose.yml так



Моя инструкция для Ubuntu:

  1. Добавляем репозиторий для свежего docker.
  2. Ставим через apt-get docker-engine
  3. Ставим docker-compose.
    curl -L https://github.com/docker/compose/releases/download/1.5.0rc1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
    и делаем его исполняемым

chmod +x /usr/local/bin/docker-compose

  1. Забираем через git docker-compose.yml и стартуем как docker-compose up.
    После этого этапа все должно завестись.
  2. Настраиваем автозапуск через систему upstart

description «Gitlab docker containers»
author «Me»
start on filesystem and started docker
stop on runlevel [!2345]
chdir /home/nexus/docker.src/docker-gitlab/

/usr/local/bin/docker-compose start -d
end script