GitLab
Following the link below, GitLab provides a good refence for the many ways to deploy and configure various portions of a self hosted GitLab instance.
Official Ubuntu Installation Instructions
Versions
GitLab offers two types of instances, SaaS and self-hosted. SaaS is their hosted gitlab.com instance which you can sign up on an purchase different tiers. The second is a self-hosted environment with limitations based on the license purchased.
SaaS
Differences in SaaS GitLab versions
Support for CI tools and dashboards come with Bronze
Support for Conan, Maven, NPM come with Silver.
Support for major security features comes with Gold.
Self-hosted
Differences in self-hosted GitLab versions
Its good to know that you can always upgrade your CE instance to EE just by installing the EE packages ontop of the CE.
Its also good to know what would happen to your instance should your subscription expire if considering a EE license
Installation
GitLab uses their Omnibus GitLab package to group the services needed to host a GitLab instance without creating confusing configuration scenarios.
GitLab can be hosted on a Pi which means you can do some tweaking to improve performance or save some resources on your host. Some options would be splitting the DBs from the host and reducing running processes. Both are described and documented in the link above.
Docker Compose
Official Compose Documentation
Currently, the basic docker-compose.yml
shown on the official documentation is seen below.
web:
image: 'gitlab/gitlab-ce:latest'
restart: always
hostname: 'gitlab.example.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.example.com'
# Add any other gitlab.rb configuration here, each on its own line
ports:
- '80:80'
- '443:443'
- '22:22'
volumes:
- '$GITLAB_HOME/config:/etc/gitlab'
- '$GITLAB_HOME/logs:/var/log/gitlab'
- '$GITLAB_HOME/data:/var/opt/gitlab'
By default, docker will name this container by prefixing the web
service name with pathname_
relevant to your current working directory. If you want to name this container add container_name: name
within the web layer of this docker-compose.yml
Required Modifications
We need to make sure to replace hostname
and external_url
with relevant URLs for our environment or starting this container will fail.
We also need to ensure that we either replace the environment varialble $GITLAB_HOME
or set it to a value relevant to your environment. Otherwise, when starting this container Docker will not be able to bind the volumes and we will not be able to modify the required configuration files within them.
If you want to see what other environment variables are set with this image, run the following command
docker run gitlab/gitlab-ce env
For this image, we see the following output.
PATH=/opt/gitlab/embedded/bin:/opt/gitlab/bin:/assets:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=0a37118aae33
LANG=C.UTF-8
TERM=xterm
HOME=/root
Serving Locally
Working on hosting this container on localhost
? Because DNS resolves locally on your host first, you can override any URL within your /etc/hosts
file by passing the below configuration, which allows us to visit www.myspace.com
within a web browser to see the content being served locally.
127.0.0.1 localhost www.myspace.com myspace.com
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
GitLab Configurations
To modify these files, which configure several back-end options for our GitLab instance, we can start and stop our services so Docker mounts the volumes containing the files we need to edit. Run docker-compose up -d
and check the directory you input for $GITLAB_HOME
in your docker-compose.yml. After a few seconds, we should notice this directory contains some new configurations. Stop the container for now with docker-compose down
and edit the configurations in the sections below.