Linux package repository mirroring

GitLab and GitLab Runner Linux packages are available at https://packages.gitlab.com. This document explains how to maintain a local mirror of these repositories.

Mirroring APT repositories

A local mirror of an apt repository can be created using the apt-mirror tool.

  1. Install apt-mirror

    sudo apt install apt-mirror
  2. Create a directory for the mirror

    sudo mkdir /srv/gitlab-repo-mirror
  3. Add the following lines to the apt-mirror configuration file present at /etc/apt/mirror.list

    set base_path /srv/gitlab-repo-mirror

    The mirrored content is written under /srv/gitlab-repo-mirror/mirror/packages.gitlab.com.

    Check the upstream example config file for other available settings.

  4. At the end of the configuration file, specify the repositories to mirror in the apt sources file URL format.

    The repository structure differs between GitLab and GitLab Runner.

    GitLab

    GitLab uses the same version strings for packages across OS distributions (with different content). That means these packages are considered Duplicate Packages as per Debian Repository Format.

    To work around this, each OS distribution (like Debian Trixie or Ubuntu Focal) gets a dedicated repository that hosts only that distribution. This results in URLs having an extra distribution component.

    GitLab Runner

    GitLab Runner is a statically linked Go binary and uses the same package for different OS distributions. It uses a single apt repository per OS and hosts all distributions of that OS within that repository.

    deb https://packages.gitlab.com/gitlab/gitlab-ee/debian/trixie trixie main
    deb-src https://packages.gitlab.com/gitlab/gitlab-ee/debian/trixie trixie main
    deb https://packages.gitlab.com/runner/gitlab-runner/debian trixie main
    deb-src https://packages.gitlab.com/runner/gitlab-runner/debian trixie main
  5. Start the mirror process

    sudo apt-mirror

Mirroring RPM repositories

A local mirror of an rpm repository can be created using reposync (to download packages) and createrepo (to generate metadata).

reposync expects the repository you want to mirror to be installed on the system. Follow the installation docs for the repository you want to mirror.

To find the repository ID, list available repositories with:

yum repolist
  1. Install createrepo and reposync

    sudo yum install createrepo yum-utils
  2. Create a directory for the mirror

    sudo mkdir /srv/gitlab-repo-mirror
  3. Run reposync. Pass the repository ID and output directory as arguments.

    reposync --repoid=gitlab_gitlab-ee --download-path=/srv/gitlab-repo-mirror
  4. Generate metadata for the repository using createrepo

    createrepo -o /srv/gitlab-repo-mirror /srv/gitlab-repo-mirror