gitlab-ce-docker Plugin

This plugin installs GitLab CE(Community Edition) on Docker.

NOTICE: currently, this plugin support Linux only.

Background

GitLab officially provides an image gitlab-ce. We can use this image to start a container:

Bash

  1. docker run --detach \
  2. --hostname gitlab.example.com \
  3. --publish 443:443 --publish 80:80 --publish 22:22 \
  4. --name gitlab \
  5. --restart always \
  6. --volume $GITLAB_HOME/config:/etc/gitlab \
  7. --volume $GITLAB_HOME/logs:/var/log/gitlab \
  8. --volume $GITLAB_HOME/data:/var/opt/gitlab \
  9. --shm-size 256m \
  10. gitlab/gitlab-ce:rc

The variable $GITLAB_HOME here pointing to the directory where the configuration, logs, and data files will reside.

We can set this variable by the export command:

Bash

  1. export GITLAB_HOME=/srv/gitlab

The GitLab container uses host mounted volumes to store persistent data:

Local locationContainer locationUsage
$GITLAB_HOME/data/var/opt/gitlabFor storing application data
$GITLAB_HOME/logs/var/log/gitlabFor storing logs
$GITLAB_HOME/config/etc/gitlabFor storing the GitLab configuration files

So, we can customize the following configurations:

  1. hostname
  2. host port
  3. persistent data path
  4. docker image tag

Configuration

Note: 1. the user you are using must be root or in the docker group; 2. https isn’t supported for now.

The following content is an example of the “tool file”.

For more information on the main config, the tool file and the var file of DevStream, see Core Concepts Overview and DevStream Configuration.

YAML

  1. tools:
  2. # name of the tool
  3. - name: gitlab-ce-docker
  4. # id of the tool instance
  5. instanceID: default
  6. # format: name.instanceID; If specified, dtm will make sure the dependency is applied first before handling this tool.
  7. dependsOn: [ ]
  8. # options for the plugin
  9. options:
  10. # hostname for running docker. (default: gitlab.example.com)
  11. hostname: gitlab.example.com
  12. # pointing to the directory where the configuration, logs, and data files will reside.
  13. # (default: /srv/gitlab)
  14. # 1. it should be a absolute path
  15. # 2. once the tool is installed, it can't be changed
  16. gitlabHome: /srv/gitlab
  17. # ssh port exposed in the host machine. (default: 22)
  18. sshPort: 22
  19. # http port exposed in the host machine. (default: 80)
  20. httpPort: 80
  21. # https port exposed in the host machine.
  22. # (default: 443)
  23. # todo: support https, reference: https://docs.gitlab.com/omnibus/settings/nginx.html#enable-https
  24. httpsPort: 443
  25. # whether to delete the gitlabHome directory when the tool is removed. (default: false)
  26. rmDataAfterDelete: false
  27. # gitlab-ce tag. (default: "rc")
  28. imageTag: "rc"

Some Commands That May Help

  • clone code

Bash

  1. export hostname=YOUR_HOSTNAME
  2. export username=YOUR_USERNAME
  3. export project=YOUR_PROJECT_NAME
  1. ssh

Bash

  1. # port is 22
  2. git clone git@${hostname}/${username}/${project}.git
  3. # port is not 22, 2022 as a sample
  4. git clone ssh://git@${hostname}:2022/${username}/${project}.git
  1. http

Bash

  1. # port is 80
  2. git clone http://${hostname}/${username}/${project}.git
  3. # port is not 80, 8080 as a sample
  4. git clone http://${hostname}:8080/${username}/${project}.git