対象者:ubuntuでソースビルドしたい物好きな人
パッケージのインストール
apt-get update -y
apt-get upgrade -y
apt-get install sudo -y
vimのインストールとデフォルトエディタをvimに
apt-get install -y vim
update-alternatives --set editor /usr/bin/vim.basic
必須パッケージのインストール
apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate python-docutils pkg-config cmake libkrb5-dev
gitのインストール
apt-get install python-software-properties
add-apt-repository ppa:git-core/ppa
apt-get update
apt-get install git
gitユーザの作成
adduser git
gpasswd -a git sudo
Rubyのインストール
sudo su - git
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install 2.3.3
rbenv global 2.3.3
gem install bundler --no-ri --no-rdoc
Goのインストール
sudo curl --remote-name --progress https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.8.linux-amd64.tar.gz
sudo ln -sf /usr/local/go/bin/{go,godoc,gofmt} /usr/local/bin/
rm go1.8.linux-amd64.tar.gz
Nodeのインストール
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
source ~/.bashrc
nvm install node
curl --location https://yarnpkg.com/install.sh | bash -
Databaseのインストール
sudo apt-get install -y postgresql postgresql-client libpq-dev postgresql-contrib
sudo -u postgres psql -d template1 -c "CREATE USER git CREATEDB;"
sudo -u postgres psql -d template1 -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
sudo -u postgres psql -d template1 -c "CREATE DATABASE gitlabhq_production OWNER git;"
Redisのインストール
sudo apt-get install redis-server
設定ファイルの修正
sudo cp /etc/redis/redis.conf /etc/redis/redis.conf.orig
sed 's/^port .*/port 0/' /etc/redis/redis.conf.orig | sudo tee /etc/redis/redis.conf
echo 'unixsocket /var/run/redis/redis.sock' | sudo tee -a /etc/redis/redis.conf
echo 'unixsocketperm 770' | sudo tee -a /etc/redis/redis.conf
mkdir /var/run/redis
chown redis:redis /var/run/redis
chmod 755 /var/run/redis
sudo service redis-server restart
sudo usermod -aG redis git
GitLabのインストール
cd /home/git
git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 9-0-stable gitlab
cd /home/git/gitlab
cp config/gitlab.yml.example config/gitlab.yml
cp config/secrets.yml.example config/secrets.yml
chmod 0600 config/secrets.yml
cp config/unicorn.rb.example config/unicorn.rb
git config --global core.autocrlf input
git config --global gc.auto 0
git config --global repack.writeBitmaps true
cp config/resque.yml.example config/resque.yml
※各configは環境に合わせて書き換えてください
DBの設定
sudo -u git cp config/database.yml.postgresql config/database.yml
vim config/database.yml
chmod o-rwx config/database.yml
Gemsのインストール
bundle install --deployment --without development test mysql aws kerberos
gitlab-shellのインストール
bundle exec rake gitlab:shell:install REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production SKIP_STORAGE_VALIDATION=true
gitlab-workhorseのインストール
bundle exec rake "gitlab:workhorse:install[/home/git/gitlab-workhorse]" RAILS_ENV=production
DBの初期化
bundle exec rake gitlab:setup RAILS_ENV=production
起動スクリプトの設置
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
sudo cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
sudo update-rc.d gitlab defaults 21
Gitalyのインストール
bundle exec rake "gitlab:gitaly:install[/home/git/gitaly]" RAILS_ENV=production
chmod 0700 /home/git/gitlab/tmp/sockets/private
chown git /home/git/gitlab/tmp/sockets/private
echo 'GITALY_SOCKET_PATH=/home/git/gitlab/tmp/sockets/private/gitaly.socket' | \
sudo -u git tee -a /home/git/gitaly/env
echo 'gitaly_enabled=true' | sudo tee -a /etc/default/gitlab
vim config/gitlab.yml
config/gitlab.yml
# <- gitlab.yml indentation starts here
gitaly:
enabled: true
ログローテートの設定
sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
assetsのコンパイル
yarn install --production --pure-lockfile
bundle exec rake gitlab:assets:compile RAILS_ENV=production NODE_ENV=production
GitLabの起動
/etc/init.d/gitlab restart