GitLab is a web-based platform for version control and collaboration on software development projects. It’s an alternative to GitHub and offers many similar features, plus some additional ones.
Here are some key aspects of GitLab:
Version Control: GitLab uses Git, a popular version control system, to manage code repositories.
Collaboration: GitLab allows teams to collaborate on projects by assigning issues, tracking progress, and reviewing code changes.
Continuous Integration/Continuous Deployment (CI/CD): GitLab offers built-in CI/CD tools to automate testing, building, and deployment of software.
Project Management: GitLab provides features like issue tracking, project roadmaps, and time tracking to help teams plan and manage their work.
Repository Management: GitLab supports public and private repositories, and offers features like code review, fork, and merge requests.
Integrated Development Environment (IDE): GitLab offers a web-based IDE for coding, testing, and debugging.
Open-Source: GitLab is open-source software, which means it’s free to use, modify, and distribute.
1) Install Docker and Docker Compose
Check this article for this step
2) Create directory and environment variable
mkdir -p /opt/gitlab/gitlab_data
# Setup environment variable temporarily
export GITLAB_HOME=/opt/gitlab/gitlab_data
3) Setup environment variable permanently
sudo nano /etc/environment
#Append the following and close the file:
GITLAB_HOME=/opt/gitlab/gitlab_data
source /etc/environment
4) Create docker-compose.yml file:
version: '3.6'
services:
web:
image: 'gitlab/gitlab-ee:latest'
restart: always
hostname: 'gilab.xyz.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.xyz.com'
gitlab_rails['gitlab_shell_ssh_port'] = 2224
ports:
- '8929:80'
- '2224:22'
volumes:
- '$GITLAB_HOME/config:/etc/gitlab'
- '$GITLAB_HOME/logs:/var/log/gitlab'
- '$GITLAB_HOME/data:/var/opt/gitlab'
shm_size: '256m'
5) Run the container
docker compose up -d
6) GMail SMTP Configuration for GitLab
1) Enable 2-Step Verification- https://support.google.com/accounts/answer/185839
2) Create App Password – https://support.google.com/mail/answer/185833
3) Login into the container:
docker exec -it <container-id> /bin/bash
Inside the container, install vim:
apt update
apt install vim
4) Inside the container, open /etc/gitlab/gitlab.rb file and configure the following:
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.gmail.com"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "<your-email>@gmail.com"
gitlab_rails['smtp_password'] = "<password>"
gitlab_rails['smtp_domain'] = "smtp.gmail.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
#gitlab_rails['smtp_pool'] = false
gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
Save and close the file and then run this command:
gitlab-ctl reconfigure
Useful links:
- https://support.google.com/accounts/answer/6010255
- https://support.google.com/accounts/answer/185839
- https://support.google.com/mail/answer/185833
- https://docs.gitlab.com/omnibus/settings/smtp.html
7) Configure a reverse proxy or load balancer SSL termination
By default, Linux package installations auto-detect whether to use SSL if external_url contains https:// and configures NGINX for SSL termination. However, if you configure GitLab to run behind a reverse proxy or an external load balancer, some environments may want to terminate SSL outside the GitLab application.
To prevent the bundled NGINX from handling SSL termination:
nginx['listen_port'] = 80
nginx['listen_https'] = false
Reconfigure GitLab:
gitlab-ctl reconfigure
Useful links: