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

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

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.1.5

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.1/ruby-3.1.5.tar.gz"
echo '3685c51eeee1352c31ea039706d71976f53d00ab6d77312de6aa1abaf5cda2c5 ruby-3.1.5.tar.gz' | sha256sum -c - && tar xzf ruby-3.1.5.tar.gz
cd ruby-3.1.5
./configure --disable-install-rdoc --enable-shared
make
sudo make install
gem update --system
gem install bundler
gem install --default bundler

Install Go 1.21.11

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

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
sudo make git GIT_PREFIX=/usr/local
sudo apt remove -y git-core git
sudo apt autoremove

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

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

Database

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

And following the official documentation section.

Redis

sudo apt-get install redis-server

And following the official documentation section.

Clone Gitlab and do some change

Largely following official document.

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
# setting go proxy
export GO111MODULE=on
export GOPROXY=https://goproxy.cn
sudo chown deployer:deployer -R .bundle/
bundle install
sudo chown git:git -R .bundle/

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

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

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

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.

cd /home/git/gitlab
sudo -u git -H bundle exec rake "gitlab:gitaly:install[/home/git/gitaly,/home/git/repositories,https://e.coding.net/sew/gitlab/gitaly.git]" RAILS_ENV=production

Some configure after install

I only record I do:

  1. trusted-proxies

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