2013年ごろからあったみたいだけど、いつものごとく素通ししてて今更ながらテスト的に使ってみる。
サーバが SakruaVPS1G です。GitHubのようなサイトを独自に運用できる「GitLab」や「GitBucket」を使ってみよう by http://knowledge.sakura.ad.jpに書かれていること+αな事。
今の構成上、Redmineが動いているサーバに無理やり突っ込む形になるので、フロント側に Nginx
が動いており、ドメインベースで Redmine
か Gitlab
か切り分けるようにさせる。
Install
GitLab Community Edition (CE) を参考にしてインストール。
OS は CentOS6
なのでそれを見ながら、ただし FireWall
は昔ながらの iptables
の設定が生きてるので、殺さないようにする。( sudo lokkit -s http -s ssh
で iptables
をいじくるコマンドなのを知らず、ssh
のポートを変えているのにコマンドを実行してしまってログアウトしてしまいサーバに入れなくなってsakura vps
のモニター画面から入ったもののUSキーボードなので :
が打ち込めないのに vim を起動してしまいつんでしまい、lokkit
を勉強しなおしたので1日潰れてたのは秘密)
$ sudo yum install curl openssh-server postfix cronie
$ sudo service postfix start
$ sudo chkconfig postfix on
$ curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
$ sudo yum install gitlab-ce
上記ので gitlab-ce
の必要な物は全部入りました。(dockerじゃないけどコンテナで一式入るみたいで、ちょっとおもしろい事になってます。)
Configuration
設定を変更
gitlab_url: "http://<任意のホスト名>/"
- /etc/gitlab/gitlab.rb では任意の設定に変更させる。
$ sudo gitlab-ctl reconfigure
フロントの Nginx 側の設定
upstream gitlab-git-http-server {
server unix://var/opt/gitlab/gitlab-git-http-server/socket fail_timeout=0;
}
upstream gitlab {
server 127.0.0.1:8080 fail_timeout=0;
}
server {
listen 80;
server_name <ホスト名>;
location / {
root /opt/gitlab/embedded/service/gitlab-rails/public;
client_max_body_size 250m;
error_page 502 /502.html;
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_set_header Host $http_host;
proxy_pass http://gitlab;
}
# http://<ホスト名>/nantoka/test.git で git clone などできるようにする
location ~ [-\/\w\.]+\.git\/ {
## If you use HTTPS make sure you disable gzip compression
## to be safe against BREACH attack.
gzip off;
## https://github.com/gitlabhq/gitlabhq/issues/694
## Some requests take more than 30 seconds.
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;
# Do not buffer Git HTTP responses
proxy_buffering off;
# The following settings only work with NGINX 1.7.11 or newer
#
# Pass chunked request bodies to gitlab-git-http-server as-is
# proxy_request_buffering off;
# proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://gitlab-git-http-server;
}
}
Redmine からの移行
移行箇所など。
-
Repository
/var/opt/gitlab/gitlab-shell/config.yml をいじれば行けるらしいけど、使ってない死んでるリポジトリとかあるので、整理目的で今回は使っているもののみ登録した
-
ユーザ
人数は少ないので管理者アカウントから人数分を作成した
-
Issue
諸事情で別アプリのを使用しているので問題なし
-
Wiki
マイグレーションが無い上、タグ互換が無いので、1日二時間をメドにチマチマやっていました。3日ぐらいかかった。
問題っぽいもの
うちだけかもしれないけど、サーバの公開鍵を Deploy Key
に設定しても
$ git clone git://git@<host>/hoge/test.git
GitLab: The project you were looking for could not be found.
fatal: The remote end hung up unexpectedly
と言われて終わるのよね…orz
2015/10/07 追記:
Deploy Key
に設定してもThe remote end hung up unexpectedly
と言われる問題の対処、できました。
Admin Area
のDeploy Keys
だけに設定していたのが原因。
Project
→Settings
→DeployKeys
に表示されている該当のDeployKeys
をEnabled
にするか、Enabled deploy keys
を新たに設定すれば使えるようになる。
ただし push
をすると
GitLab: Deploy keys are not allowed to push code.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
と言われDeploy
専用となる。
参考
- GitHubのようなサイトを独自に運用できる「GitLab」や「GitBucket」を使ってみよう by http://knowledge.sakura.ad.jp
- Download GitLab Community Edition (CE)
後何か https://github.com/composer/satis を使えば composer で使う時に嬉しいことがありそうだけど気力尽きたのでまた今度。