GitLab Tutorial
- 1. Introduction to GitLab
- 2. Architecture & Self-Hosting
- 3. Groups, Projects & Namespaces
- 4. Issue Tracking & Agile
- 5. GitLab CI/CD Basics
- 6. GitLab Runners & Executors
- 7. Environments & Deployments
- 8. Merge Requests & Code Review
- 9. GitLab Container Registry
- 10. Package & Infra Registry
- 11. Security & Compliance
- 12. Monitoring & Analytics (DORA)
- 13. GitLab Pages Hosting
- 14. APIs, Webhooks & Integrations
- 15. GitLab Workflow & Best Practices
2. GitLab Architecture & Self-Hosting
One of GitLab’s greatest strengths is its architectural flexibility. Unlike platforms that are strictly SaaS, GitLab is designed from the ground up to be deployed on-premise, inside custom private clouds, or on managed container platforms like Kubernetes.
GitLab Deployment Models
You can consume and host GitLab in three main ways:
- GitLab SaaS (GitLab.com): Managed entirely by GitLab. You create an account, create groups, and start coding immediately. No installation or infrastructure maintenance required.
- GitLab Self-Managed (Omnibus): Installed on a single virtual machine or server (typically Ubuntu, CentOS, or Debian). This uses GitLab's "Omnibus" package, which contains all components pre-configured.
- GitLab Cloud-Native (Kubernetes / Helm): Designed to run on a container orchestrator. It scales horizontally, separating stateless workloads from stateful data stores.
Under the Hood: Inside the GitLab Monolith
Although it appears to users as a single dashboard, GitLab's backend is a highly optimized set of microservices centered around a Ruby on Rails application:
- Workhorse: A reverse-proxy daemon written in Go that handles heavy HTTP requests (such as git push/pull, file transfers, and ZIP downloads) to free up Rails threads.
- Puma: The web server running the core Ruby on Rails web framework.
- Gitaly: A Git RPC service written in Go. Instead of having the Rails app read local Git disk paths directly, Gitaly provides high-performance access to repositories stored on disk.
- Sidekiq: A background job controller that processes asynchronous work like sending emails, processing webhooks, and trigger pipelines.
- PostgreSQL: The primary relational database holding project settings, user accounts, merge requests, issues, and pipelines.
- Redis: An in-memory cache and key-value store for caching sessions, background queues, and real-time page updates.
Setting Up GitLab Locally with Docker
The easiest way to test GitLab's self-managed environment is by spinning up the official Docker container. Below is a standard `docker-compose.yml` to launch GitLab locally:
version: '3.6'
services:
web:
image: 'gitlab/gitlab-ce:latest'
restart: always
hostname: 'localhost'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://localhost:8989'
# Add any custom configuration here
ports:
- '8989:8989'
- '2222:22'
volumes:
- './config:/etc/gitlab'
- './logs:/var/log/gitlab'
- './data:/var/opt/gitlab'
shm_size: '256m'To run this docker setup, simply run:
docker-compose up -dOnce started, you can access your local GitLab instance at `http://localhost:8989`. The default username is `root`, and the initial password can be retrieved from `./config/initial_root_password` inside the container host directories.