Deploy GitLab on RamNode

    Self-hosted DevOps platform with source code management, CI/CD pipelines, issue tracking, and container registry.

    DevOps
    Self-Hosted
    ⏱️ 30 minutes

    Introduction

    GitLab is a comprehensive DevOps platform that provides source code management, CI/CD pipelines, issue tracking, container registry, and much more in a single application. By self-hosting GitLab on RamNode, you benefit from full data ownership, customizable configurations, and the performance of dedicated VPS resources without recurring per-user licensing fees.

    Source Control

    Git repository management with merge requests

    CI/CD Pipelines

    Automated testing and deployment workflows

    Issue Tracking

    Built-in project management and tracking

    Container Registry

    Store and manage Docker images

    System Requirements

    GitLab is a resource-intensive application. Selecting the appropriate RamNode VPS plan is crucial for optimal performance.

    ResourceMinimumRecommendedProduction
    CPU Cores2 cores4 cores8+ cores
    RAM4 GB8 GB16+ GB
    Storage40 GB SSD100 GB SSD250+ GB SSD
    UsersUp to 100Up to 500500+

    ⚠️ Note: GitLab recommends a minimum of 4 GB RAM. With less memory, GitLab may run slowly or fail to start. Consider enabling swap space as a safety buffer.

    Prerequisites

    Before beginning the installation, ensure you have:

    • A RamNode VPS with Ubuntu 22.04 LTS or 24.04 LTS installed
    • Root or sudo access to your server
    • A registered domain name pointing to your VPS IP address
    • SSH access configured for secure remote management
    • Basic familiarity with Linux command line operations
    4

    Initial Server Setup

    Update System Packages

    sudo apt update && sudo apt upgrade -y

    Install Required Dependencies

    sudo apt install -y curl openssh-server ca-certificates tzdata perl

    Configure Firewall

    sudo ufw allow OpenSSH
    sudo ufw allow http
    sudo ufw allow https
    sudo ufw enable

    Configure Swap Space (Recommended)

    If your VPS has limited RAM, add swap space to prevent out-of-memory issues:

    sudo fallocate -l 4G /swapfile
    sudo chmod 600 /swapfile
    sudo mkswap /swapfile
    sudo swapon /swapfile
    echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
    5

    GitLab Installation

    Add GitLab Repository

    curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash

    Install GitLab CE

    Install GitLab Community Edition, replacing the URL with your domain:

    sudo EXTERNAL_URL="https://gitlab.yourdomain.com" apt install gitlab-ce

    💡 Important: Replace "gitlab.yourdomain.com" with your actual domain name. This URL will be used for all GitLab access and must have proper DNS records pointing to your VPS IP.

    Retrieve Initial Root Password

    sudo cat /etc/gitlab/initial_root_password

    ⚠️ Security Note: This password file is automatically deleted after 24 hours. Save the password securely and change it immediately after your first login.

    6

    Post-Installation Configuration

    Access GitLab Web Interface

    1. Open your browser and navigate to your GitLab URL (https://gitlab.yourdomain.com)
    2. Log in with username "root" and the password from the previous step
    3. Navigate to User Settings → Password to set a new secure password
    4. Configure two-factor authentication for enhanced security
    7

    Configure Email Notifications

    Edit the GitLab configuration file to set up email:

    sudo nano /etc/gitlab/gitlab.rb

    Add or modify the following SMTP settings (example using Gmail):

    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'] = "your-app-password"
    gitlab_rails['smtp_domain'] = "smtp.gmail.com"
    gitlab_rails['smtp_authentication'] = "login"
    gitlab_rails['smtp_enable_starttls_auto'] = true
    gitlab_rails['gitlab_email_from'] = "gitlab@yourdomain.com"

    Apply the configuration changes:

    sudo gitlab-ctl reconfigure
    8

    SSL/TLS Configuration

    GitLab automatically configures Let's Encrypt SSL when installed with an HTTPS external URL. Ensure these settings are in /etc/gitlab/gitlab.rb:

    letsencrypt['enable'] = true
    letsencrypt['contact_emails'] = ['admin@yourdomain.com']
    letsencrypt['auto_renew'] = true

    Manual Certificate Renewal

    sudo gitlab-ctl renew-le-certs
    9

    Backup Configuration

    Manual Backup

    Create a full backup of your GitLab instance:

    sudo gitlab-backup create

    Backups are stored in /var/opt/gitlab/backups by default.

    Automated Backups with Cron

    Set up daily automated backups:

    sudo crontab -e

    Add the following line for daily 2 AM backups:

    0 2 * * * /opt/gitlab/bin/gitlab-backup create CRON=1

    Backup Configuration Files

    ⚠️ Important: The backup command does not include configuration files. Manually backup these critical files:

    sudo cp /etc/gitlab/gitlab.rb /var/opt/gitlab/backups/
    sudo cp /etc/gitlab/gitlab-secrets.json /var/opt/gitlab/backups/
    10

    Performance Optimization

    Optimize GitLab for your VPS resources by adjusting these settings in /etc/gitlab/gitlab.rb:

    Reduce Memory Usage (4-8 GB RAM)

    # Reduce Puma workers
    puma['worker_processes'] = 2
    
    # Reduce Sidekiq concurrency
    sidekiq['concurrency'] = 10
    
    # Reduce PostgreSQL shared buffers
    postgresql['shared_buffers'] = "256MB"
    
    # Disable monitoring if not needed
    prometheus_monitoring['enable'] = false

    Apply changes after editing:

    sudo gitlab-ctl reconfigure
    11

    Troubleshooting

    GitLab Not Starting

    Check service status and logs:

    sudo gitlab-ctl status
    sudo gitlab-ctl tail

    502 Bad Gateway Errors

    This usually indicates Puma hasn't finished starting. Wait a few minutes or check memory:

    free -h
    sudo gitlab-ctl restart puma

    SSL Certificate Issues

    If Let's Encrypt fails, verify DNS and retry:

    sudo gitlab-ctl reconfigure
    sudo gitlab-ctl renew-le-certs
    12

    Command Reference

    Check statusgitlab-ctl status
    Restart all servicesgitlab-ctl restart
    Apply config changesgitlab-ctl reconfigure
    View live logsgitlab-ctl tail
    Create backupgitlab-backup create
    Run diagnosticsgitlab-rake gitlab:check