Eric Guo's blog.cloud-mes.com

Hoping writing JS, Ruby & Rails and Go article, but fallback to DevOps note

Install Gitlab 14.6 on Ubuntu 20.04 Log

Permalink

Installation gitlab from source is not easy, but it's worth as it enable me do some edit latter, so here is my installation log.

Create git user and make git user sudo

Create git user and make git user sudo
adduser deployer
sudo su - deployer
mkdir .ssh
chmod 700 .ssh
vi .ssh/authorized_keys # and paste your public key
chmod 600 .ssh/authorized_keys
sudo su -
cd /etc/sudoers.d/
echo "deployer ALL=(ALL) NOPASSWD:ALL" > 20-deployer-user

Install build dependencies

Install build dependencies
sudo apt remove libcurl4 # see https://askubuntu.com/a/1134120/111945
sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libre2-dev \
libreadline-dev libncurses5-dev libffi-dev curl openssh-server libxml2-dev libxslt-dev \
libcurl4-openssl-dev libicu-dev logrotate rsync python-docutils pkg-config cmake runit-systemd

Install Ruby 3.3.11

Install Ruby 3.3.11
sudo apt install git git-lfs autoconf bison libgmp3-dev
mkdir /tmp/ruby && cd /tmp/ruby
curl --remote-name --progress-bar "https://cache.ruby-china.com/pub/ruby/3.3/ruby-3.3.11.tar.gz"
echo '59f0fafb1a59a05dc3765117af3fa68e153eb48254708549f321c1e9e078d7a0 ruby-3.3.11.tar.gz' | sha256sum -c - && tar xzf ruby-3.3.11.tar.gz
cd ruby-3.3.11
./configure --disable-install-rdoc --enable-shared
make
sudo make install
gem update --system
gem install bundler
gem install --default bundler

Install Go 1.25.12

Install Go 1.25.12
wget https://go.dev/dl/go1.25.12.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.25.12.linux-amd64.tar.gz
sudo ln -sf /usr/local/go/bin/{go,gofmt} /usr/local/bin/
rm go1.25.12.linux-amd64.tar.gz

Install Git in gitlab versions

Install Git in gitlab versions
sudo apt-get install -y libcurl4-openssl-dev libexpat1-dev gettext libz-dev libssl-dev libpcre2-dev build-essential git-core
git clone https://e.coding.net/sew/gitlab/gitaly.git -b 14-6-stable /tmp/gitaly
cd /tmp/gitaly
# if meson is not system level
# export PATH=/home/deployer/.local/bin:/home/deployer/.rbenv/shims:/home/deployer/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
# sudo -H env PATH="/home/git/.local/bin:/usr/local/lib/ruby/gems/3.2.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" make git GIT_PREFIX=/usr/local
sudo make git GIT_PREFIX=/usr/local
sudo apt remove -y git-core git
sudo apt autoremove
# install gitaly
sudo -u git -H env PATH="/home/git/.local/bin:/usr/local/lib/ruby/gems/3.2.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" \
RAILS_ENV=production \
bundle exec rake "gitlab:gitaly:install[/home/git/gitaly,/home/git/repositories]"

Install Node.js 14 and other depends

Install Node.js 14 and other depends
sudo apt-get install -y graphicsmagick
sudo apt-get install -y postfix
sudo apt-get install -y libimage-exiftool-perl
curl --location "https://deb.nodesource.com/setup_14.x" | sudo bash -
sudo apt-get install -y gcc g++ make
sudo apt-get install -y nodejs
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn

System users

System users
sudo adduser --disabled-login --gecos 'GitLab' git

Database

Database
sudo apt install -y postgresql postgresql-client libpq-dev postgresql-contrib

And following the official documentation section.

Redis

Redis
sudo apt-get install redis-server

And following the official documentation section.

Clone Gitlab and do some change

Largely following official document.

Clone the GitLab source repository
sudo -u git -H git clone https://e.coding.net/sew/gitlab/gitlab.git -b thape_deploy gitlab
  • need change database.yml to using local user
  • need filling the config/secrets.yml with proper secrets by running rails secret
  • need setting the proxy for go
Configure the Go module proxy
# setting go proxy
export GO111MODULE=on
export GOPROXY=https://goproxy.cn
Install GitLab bundle dependencies
sudo chown deployer:deployer -R .bundle/
bundle install
sudo chown git:git -R .bundle/

Install GitLab Shell

Install GitLab Shell
cd /usr/bin
sudo ln -s /usr/local/bin/git git
sudo -u git -H bundle exec rake gitlab:shell:install RAILS_ENV=production
cd /home/git/gitlab-shell/
sudo -u git -H make
cd /home/git/gitlab/
sudo -u git -H bundle exec rake gitlab:shell:install RAILS_ENV=production

Install GitLab Workhorse

Install GitLab Workhorse
sudo -u git -H bundle exec rake "gitlab:workhorse:install[/home/git/gitlab-workhorse,https://e.coding.net/sew/gitlab/gitlab-workhorse]" RAILS_ENV=production
cd /home/git/gitlab-workhorse
sudo -u git -H git checkout -b 8-65-stable
cd /home/git/gitlab
sudo -u git -H bundle exec rake "gitlab:workhorse:install[/home/git/gitlab-workhorse,https://e.coding.net/sew/gitlab/gitlab-workhorse]" RAILS_ENV=production

Install GitLab-Elasticsearch-indexer on Enterprise Edition

Install GitLab-Elasticsearch-indexer on Enterprise Edition
sudo su - git
cd /home/git
git clone https://e.coding.net/sew/gitlab/gitlab-elasticsearch-indexer.git
logout
cd /usr/bin
sudo ln -s /usr/local/go/bin/go go
cd /home/git/gitlab
sudo -u git -H bundle exec rake "gitlab:indexer:install[/home/git/gitlab-elasticsearch-indexer,https://e.coding.net/sew/gitlab/gitlab-elasticsearch-indexer.git]" RAILS_ENV=production

Install GitLab Pages

Install GitLab Pages
cd /home/git
sudo -u git -H git clone https://e.coding.net/sew/gitlab/gitlab-pages.git
cd gitlab-pages
sudo -u git -H git checkout v$(</home/git/gitlab/GITLAB_PAGES_VERSION)
sudo -u git -H make

Install Gitaly

Beside following documents, also need to do a bundler install in ruby folder and configure-authentication.

Install Gitaly
cd /home/git/gitlab
sudo -u git -H env PATH="/home/git/.local/bin:/usr/local/lib/ruby/gems/3.2.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" \
bundle exec rake "gitlab:gitaly:install[/home/git/gitaly,/home/git/repositories]" RAILS_ENV=production

Some configure after install

I only record I do:

  1. trusted-proxies

Backup

Backup
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
# find backup at ./gitlab/tmp/backups

Comments