Gitlab auf Uberspace
DISCLAIMER: Das ist verdammt furchtbar viel Kram. Ich lege hier keinerlei Wert auf Vollständigkeit und werde keinen Support geben. Anmerkungen sind herzlich willkommen.
Vorlagen:
new git version
$ toast arm https://git-core.googlecode.com/files/git-1.9.0.tar.gz
$ git --version
-> git version 1.9.0
cmake
$ toast arm http://www.cmake.org/files/v3.0/cmake-3.0.1.tar.gz
Redis
$ test -d ~/service || uberspace-setup-svscan
$ uberspace-setup-redis
Ruby 2.2.1
SSH-Keys werden innerhalb GitLab über die GitLab Shell
verwaltet. Da diese SSH-Keys direkt auf das GitLab Shell
-Script verweisen, wird .bash_profile
nicht geladen. Deshalb müssen die $PATH
-Angaben die den neuen Rubypfad, sowie den Ruby-Gem-Pfad hinzufügen aus der .bash_profile
in .bashrc
kopiert werden.
$ cat <<'__EOF__' >> ~/.bashrc
export PATH=/package/host/localhost/ruby-2.1.1/bin:$PATH
export PATH=$HOME/.gem/ruby/2.1.0/bin:$PATH
__EOF__
$ . ~/.bashrc
$ ruby --version
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]
$ echo "gem: --user-install --no-rdoc --no-ri" > ~/.gemrc
Bundler
$ gem install bundler
gitlab-shell
checkout from github
$ cd ~
$ git clone https://github.com/gitlabhq/gitlab-shell.git
$ cd gitlab-shell
$ GITLABSHELLLATEST=$(git tag -l | tail -n 1)
$ echo $GITLABSHELLLATEST
v1.9.6
$ git checkout tags/$GITLABSHELLLATEST
Note: checking out 'tags/v1.9.6'.
now the config
$ GITLABURL="gitlab.$USER.`hostname`"
$ cp config.yml.example config.yml
$ sed -i "s/user: git/user: $USER/g" config.yml
$ sed -i "s/\/home\/git/\/home\/$USER/g" config.yml
$ sed -i "s/\/usr\/bin\/redis-cli/\/usr\/local\/bin\/redis-cli/g" config.yml
$ sed -i "s/host: 127.0.0.1/# host: 127.0.0.1/g" config.yml
$ sed -i "s/port: 6379/# port: 6379/g" config.yml
$ sed -i "s/# socket: \/tmp\/redis.socket/socket: \/home\/$USER\/.redis\/sock/g" config.yml
$ sed -i "s/http:\/\/localhost/https:\/\/$GITLABURL/g" config.yml
$ sed -i "s/self_signed_cert: false/self_signed_cert: true/g" config.yml
install
$ ./bin/install
gitlab
checkout
$ cd ~
$ git clone https://github.com/gitlabhq/gitlabhq.git gitlab
$ cd gitlab/
without rc, pre-Versions:
$ GITLABLATEST=$(git tag -l | grep -v rc | grep -v pre | tail -n 1)
$ git checkout tags/$GITLABLATEST
Note: checking out 'tags/v7.0.0'.
gitlab config
$ cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
$ mkdir -p /home/$USER/gitlab-satellites
$ chmod u+rwx,g=rx,o-rwx /home/$USER/gitlab-satellites
$ chmod -R u+rwX log tmp public
$ git config --global user.name "$USER"
$ git config --global user.email "$USER@`hostname`"
$ git config --global core.autocrlf input
#### config/gitlab.yml
$ cp config/gitlab.yml.example config/gitlab.yml
$ sed -i "s/\/home\/git\//\/home\/$USER\//g" config/gitlab.yml
$ sed -i "s/localhost/$GITLABURL/g" config/gitlab.yml
$ sed -i "s/\/usr\/bin\/git/\/home\/$USER\/.toast\/armed\/bin\/git/g" config/gitlab.yml
$ sed -i "s/# user: git/user: $USER/g" config/gitlab.yml
$ sed -i "s/https: false/https: true/g" config/gitlab.yml
$ sed -i "s/port: 80/port: 443/g" config/gitlab.yml
$ sed -i"s/#ssh_host:ssh.host_example.com/ssh_host:`hostname`/g" config/gitlab.yml
config/unicorn.rb
$ cp config/unicorn.rb.example config/unicorn.rb
Port
$ GITLABPORT=$(( $RANDOM % 4535 + 61000)); netstat -tulpen | grep $GITLABPORT
-> keine Ausgabe? Gut.
$ echo $GITLABPORT;
$ sed -i "s/\/home\/git\//\/home\/$USER\//g" config/unicorn.rb
$ sed -i "s/8080/$GITLABPORT/g" config/unicorn.rb
config/resque.yml
$ cp config/resque.yml.example config/resque.yml
$ sed -i "s/redis:\/\/redis.example.com:6379/'unix:\/home\/$USER\/.redis\/sock'/g" config/resque.yml
config/database.yml ==
$ cp config/database.yml.mysql config/database.yml
$ MYSQLPASSWORD=$(cat ~/.my.cnf | grep password | sed 's/ //g' | sed -e 's/\(^.*=\)\(.*\)\(#.*$\)/\2/')
$ sed -i "0,/RE/s/username: git/username: $USER/g" config/database.yml
$ sed -i "0,/RE/s/gitlabhq_production/"$USER"_gitlab/g" config/database.yml
$ sed -i "0,/RE/s/\"secure password\"/\"$MYSQLPASSWORD\"/g" config/database.yml
$ chmod o-rwx config/database.yml
create database
$ echo "create database "$USER"_gitlab" | mysql
Hack a little bit to get Redis socket used at all times
$ sed -i "s/config\.cache_store = :redis_store, resque_url, {namespace: 'cache:gitlab'}/config\.cache_store = :redis_store, {:url => resque_url}, {namespace: 'cache:gitlab'}/g" config/environments/production.rb
$ sed -i "s/config\.serve_static_assets = false/config\.serve_static_assets = true/g" config/environments/production.rb
Install Bundle Gems (CentOS 5)
Achtung: Gabriel Bretschner Hat darauf hingewiesen, dass es auf Servern unter CentOS 5 zu Problemen mit Charlock Holmes kommen kann. Die Lösung ist recht einfach und stammt aus dem Uberspace-Wiki:
$ bundle config build.charlock_holmes --with-icu-dir=/package/host/localhost/icu4c
install gitlab
$ bundle install --deployment --without development test postgres aws
init db
$ bundle exec rake gitlab:setup RAILS_ENV=production
[...]
Administrator account created:
login.........admin@local.host
password......5iveL!fe
.htaccess
$ mkdir /var/www/virtual/$USER/$GITLABURL
$ cat <<__EOF__> /var/www/virtual/$USER/$GITLABURL/.htaccess
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{ENV:HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteBase /
RewriteRule ^(.*)$ http://127.0.0.1:$GITLABPORT/\$1 [P]
RequestHeader set X-Forwarded-Proto https
__EOF__
final checks and debug
$ git config --global user.name "$USER"
$ git config --global user.email "$USER@`hostname`"
$ bundle exec rake gitlab:env:info RAILS_ENV=production
$ bundle exec rake gitlab:check RAILS_ENV=production
$ bundle exec rake assets:precompile RAILS_ENV=production
test:
$ sed -i "s/app_user=\"git\"/app_user=\"$USER\"/g" lib/support/init.d/gitlab
$ ./lib/support/init.d/gitlab start
login.........admin@local.host
password......5iveL!fe
daemontools
WORK IN PROGRESS
sidekiq
#!/bin/sh
# These environment variables are sometimes needed by the running daemons
export USER=gitlabmo
export HOME=/home/gitlabmo
# Include the user-specific profile
. $HOME/.bash_profile
export RAILS_ENV="production"
export GITLAB_PATH="$HOME/gitlab"
# Now let's go!
cd $GITLAB_PATH/
app_root=$(pwd)
sidekiq_pidfile="$app_root/tmp/pids/sidekiq.pid"
exec bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e $RAILS_ENV -P $sidekiq_pidfile 2>&1
unicorn
#!/bin/sh
# These environment variables are sometimes needed by the running daemons
export USER=gitlabmo
export HOME=/home/gitlabmo
# Include the user-specific profile
. $HOME/.bash_profile
# Now let's go!
export RAILS_ENV="production"
export GITLAB_PATH="$HOME/gitlab"
cd $GITLAB_PATH/
app_root=$(pwd)
unicorn_config="$app_root/config/unicorn.rb"
exec bundle exec unicorn_rails -c $unicorn_config -E $RAILS_ENV 2>&1