jail 環境に gitlab をインストール
FreeBSD の jail 環境に gitlab をインストールして一通り使えるようになった.いくつかハマッた点をメモ.
rbenv で ruby をインストールしようとしたが JavaScript の実行環境 (libv8 とか therubyrace とか) が上手く動かなくて断念.ruby は pkg でインストールした.libv8 のインストールのため gcc49 も pkg でインストール.pkg でインストールしたもの一覧はこのページの末尾で.
bundle install のときに /usr/local の下を見に行くようにいくつか追加設定.
$ bundle config Settings are listed in order of priority. The top value will be used. build.charlock_holmes Set for the current user (/home/git/.bundle/config): "--with-opt-dir=/usr/local" build.nokogiri Set for the current user (/home/git/.bundle/config): "--with-opt-dir=/usr/local" build.libv8 Set for the current user (/home/git/.bundle/config): "--with-opt-dir=/usr/local" frozen Set for your local app (/usr/home/git/gitlab/.bundle/config): "1" path Set for your local app (/usr/home/git/gitlab/.bundle/config): "vendor/bundle" without Set for your local app (/usr/home/git/gitlab/.bundle/config): "development:test:mysql:aws" disable_shared_gems Set for your local app (/usr/home/git/gitlab/.bundle/config): "1"
jail 環境内では http (nginx)は80番ポート,sshは22番ポートでそれぞれ立ち上げるのだが,一つしか無いグローバルアドレスのこれらのポートは既に別の用途に利用しているので,外部からのアクセス用にそれぞれ5780番と5722番ポートを利用する.57 なのはjail環境のプライベートアドレスが 192.168.0.57 に合わせただけで意味はない.
グローバルアドレスの5780や5722から、jail内の80や22へのリダイレクトは、ホスト環境の pf で.
ext_if0="em0" jail_git="192.168.0.57" # gitlab http and ssh rdr on {$ext_if0} proto tcp from any to port 5780 -> $jail_git port 80 rdr on {$ext_if0} proto tcp from any to port 5722 -> $jail_git port 22
これに合わせた gitlab の設定変更。
$ diff -u config/gitlab.yml.example config/gitlab.yml --- config/gitlab.yml.example 2014-07-01 22:42:32.000000000 +0900 +++ config/gitlab.yml 2014-07-10 11:28:04.000000000 +0900 @@ -15,14 +15,15 @@ ## GitLab settings gitlab: ## Web server settings (note: host is the FQDN, do not include http://) - host: localhost - port: 80 + host: git.example.net + port: 5780 https: false # Uncommment this line below if your ssh host is different from HTTP/HTTPS one # (you'd obviously need to replace ssh.host_example.com with your own host). # Otherwise, ssh host will be set to the `host:` value above # ssh_host: ssh.host_example.com + ssh_host: git.example.net # WARNING: See config/application.rb under "Relative url support" for the list of # other files that need to be changed for relative url support @@ -33,7 +34,8 @@ ## Email settings # Email address used in the "From" field in mails sent by GitLab - email_from: example@example.com + #email_from: example@example.com + email_from: git@example.net # Email server smtp settings are in [a separate file](initializers/smtp_settings.rb.sample). @@ -216,12 +218,13 @@ # If you use non-standard ssh port you need to specify it # ssh_port: 22 + ssh_port: 5722 ## Git settings # CAUTION! # Use the default values unless you really know what you are doing git: - bin_path: /usr/bin/git + bin_path: /usr/local/bin/git # The next value is the maximum memory size grit can use # Given in number of bytes per git object (e.g. a commit) # This value can be increased if you have very large commits
/etc/rc.conf の内容
sendmail_enable="NONE" sendmail_submit_enable="YES" sshd_enable="YES" postgresql_enable="YES" nginx_enable="YES" redis_enable="YES"
/etc/hosts の内容
192.168.0.57 localhost localhost.example.net git.example.net
/etc/init.d/ に置く自動起動スクリプトは FreeBSD ではちゃんと動かなさそうなので,とりあえず手動で起動.
$ env|grep RAILS_ENV RAILS_ENV=production $ ./bin/web start $ ./bin/background_jobs start
FreeBSD の特殊環境(?)に合わせて redis の設定を修正./home が /usr/home へのシンボリックリンクで設定ファイルには実体を書かないといけないのと,redis-cli が /usr/local/bin に入っているのに合わせる.
$ cat ~/gitlab-shell/config.yml --- user: git gitlab_url: http://localhost/ http_settings: self_signed_cert: false repos_path: "/usr/home/git/repositories/" auth_file: "/usr/home/git/.ssh/authorized_keys" redis: bin: /usr/local/bin/redis-cli host: localhost port: 6379 namespace: resque:gitlab log_level: INFO audit_usernames: false
だいたい、このくらいの修正で動くようになったと思う.
pkg でインストールしたもの.
$ pkg info autoconf-2.69 Automatically configure source code on many Un*x platforms autoconf-wrapper-20131203 Wrapper script for GNU autoconf bash-4.3.18_2 The GNU Project's Bourne Again SHell binutils-2.24 GNU binary tools ca_root_nss-3.16.1 The root certificate bundle from the Mozilla Project curl-7.37.0 Non-interactive tool to get files from FTP, GOPHER, HTTP(S) servers cvsps-2.1_1 Create patchset information from CVS dialog4ports-0.1.5_2 Console Interface to configure ports expat-2.1.0_1 XML 1.0 parser written in C gcc-ecj-4.5 Eclipse Java Compiler used to build GCC Java gcc49-4.9.1.s20140618 GNU Compiler Collection 4.9 gettext-0.18.3.1_1 GNU gettext package git-2.0.0 Distributed source code management tool gmake-3.82_1 GNU version of 'make' utility gmake-lite-3.82 Minimalist version of gnu make gmp-5.1.3_2 Free library for arbitrary precision arithmetic help2man-1.43.3_1 Automatically generating simple manual pages from program output icu-53.1 International Components for Unicode (from IBM) indexinfo-0.2 Utility to regenerate the GNU info page index libexecinfo-1.1_3 Library for inspecting program's backtrace libffi-3.0.13_1 Foreign Function Interface libiconv-1.14_3 Character set conversion library libxml2-2.9.1_1 XML parser library for GNOME libyaml-0.1.6 A YAML 1.1 parser and emitter written in C m4-1.4.17_1,1 GNU m4 mpc-1.0.2 Library of complex numbers with arbitrarily high precision mpfr-3.1.2_2 Library for multiple-precision floating-point computations nginx-1.6.0_2,2 Robust and small WWW server p5-Authen-SASL-2.16 Perl5 module for SASL authentication p5-Digest-HMAC-1.03 Perl5 interface to HMAC Message-Digest Algorithms p5-Error-0.17022 Error/exception handling in object-oriented programming style p5-GSSAPI-0.28 Perl extension providing access to the GSSAPIv2 library p5-IO-Socket-IP-0.29 Drop-in replacement for IO::Socket::INET supporting IPv4 and IPv6 p5-IO-Socket-SSL-1.994 Perl5 interface to SSL sockets p5-MIME-Base64-3.14 Perl5 module for Base64 and Quoted-Printable encodings p5-Net-SMTP-SSL-1.01_2 SSL support for Net::SMTP p5-Net-SSLeay-1.64 Perl5 interface to SSL p5-Socket-2.014 Networking constants and support functions pcre-8.34_1 Perl Compatible Regular Expressions library perl5-5.16.3_11 Practical Extraction and Report Language pkg-1.2.7_3 Package manager postgresql91-client-9.1.13_1 PostgreSQL database (client) postgresql91-server-9.1.13_1 The most advanced open-source database available anywhere python2-2_2 The "meta-port" for version 2 of the Python interpreter python27-2.7.6_4 Interpreted object-oriented programming language readline-6.3.6_1 Library for editing command lines as they are typed redis-2.8.11 Persistent key-value database with built-in net interface ruby21-2.1.1_2,1 Object-oriented interpreted scripting language ruby21-gems-1.8.29 Package management framework for the Ruby language rubygem-bundler-1.5.3 A tool that manages gem dependencies for ruby applications rubygem-rake-10.3.2 Ruby Make texinfo-lite-5.2 Minimal version of texinfo v8-3.18.5 Google\'s open source JavaScript engine
bundle install でインストールされたもの
% bundle list Gems included by the bundle: * ace-rails-ap (2.0.1) * actionmailer (4.1.1) * actionpack (4.1.1) * actionview (4.1.1) * activemodel (4.1.1) * activerecord (4.1.1) * activesupport (4.1.1) * acts-as-taggable-on (2.4.1) * arel (5.0.1.20140414130214) * asciidoctor (0.1.4) * axiom-types (0.0.5) * bcrypt-ruby (3.1.2) * bootstrap-sass (3.0.3.0) * builder (3.2.2) * bundler (1.5.3) * carrierwave (0.9.0) * celluloid (0.15.2) * charlock_holmes (0.6.9.4) * coercible (1.0.0) * coffee-rails (4.0.1) * coffee-script (2.2.0) * coffee-script-source (1.6.3) * colored (1.2) * connection_pool (1.2.0) * d3_rails (3.1.10) * default_value_for (3.0.0) * descendants_tracker (0.0.3) * devise (3.0.4) * devise-async (0.8.0) * diff-lcs (1.2.5) * diffy (3.0.3) * dotenv (0.9.0) * dropzonejs-rails (0.4.14) * emoji (1.0.1) * enumerize (0.7.0) * equalizer (0.0.8) * erubis (2.7.0) * escape_utils (0.2.4) * eventmachine (1.0.3) * execjs (2.0.2) * faraday (0.8.8) * faraday_middleware (0.9.0) * font-awesome-rails (3.2.1.3) * foreman (0.63.0) * gemnasium-gitlab-service (0.2.1) * github-markup (1.1.0) * gitlab-flowdock-git-hook (0.4.2.2) * gitlab-grack (2.0.0.pre) * gitlab-grit (2.6.9) * gitlab-linguist (3.0.0) * gitlab_emoji (0.0.1.1) * gitlab_git (6.0.0) * gitlab_meta (7.0) * gitlab_omniauth-ldap (1.0.4) * gollum-lib (3.0.0) * gon (5.0.1) * grape (0.6.1) * grape-entity (0.4.2) * haml (4.0.5) * haml-rails (0.5.3) * hashie (2.0.5) * hike (1.2.3) * hipchat (0.14.0) * http_parser.rb (0.5.3) * httparty (0.13.0) * httpauth (0.2.0) * i18n (0.6.9) * ice_nine (0.10.0) * jquery-atwho-rails (0.3.3) * jquery-rails (3.1.0) * jquery-scrollto-rails (1.4.3) * jquery-turbolinks (2.0.1) * jquery-ui-rails (4.2.1) * json (1.8.1) * jwt (0.1.8) * kaminari (0.15.1) * kgio (2.8.1) * libv8 (3.16.14.3) * mail (2.5.4) * mime-types (1.25.1) * mini_portile (0.6.0) * minitest (5.3.4) * multi_json (1.10.1) * multi_xml (0.5.5) * multipart-post (1.2.0) * net-ldap (0.3.1) * nokogiri (1.6.2.1) * nprogress-rails (0.1.2.3) * oauth (0.4.7) * oauth2 (0.8.1) * omniauth (1.1.4) * omniauth-github (1.1.1) * omniauth-google-oauth2 (0.2.1) * omniauth-oauth (1.0.1) * omniauth-oauth2 (1.1.1) * omniauth-twitter (1.0.1) * org-ruby (0.9.6) * orm_adapter (0.5.0) * pg (0.15.1) * polyglot (0.3.4) * posix-spawn (0.3.8) * protected_attributes (1.0.5) * pyu-ruby-sasl (0.0.3.3) * rack (1.5.2) * rack-accept (0.4.5) * rack-attack (2.3.0) * rack-cors (0.2.9) * rack-mount (0.8.3) * rack-protection (1.5.1) * rack-test (0.6.2) * rails (4.1.1) * rails-observers (0.1.2) * rails_autolink (1.1.6) * railties (4.1.1) * raindrops (0.12.0) * rake (10.3.2) * raphael-rails (2.1.2) * redcarpet (2.2.2) * redis (3.0.6) * redis-actionpack (4.0.0) * redis-activesupport (4.0.0) * redis-namespace (1.4.1) * redis-rack (1.5.0) * redis-rails (4.0.0) * redis-store (1.1.4) * ref (1.0.5) * rouge (1.3.3) * rubyntlm (0.1.1) * rubypants (0.2.0) * rugged (0.19.0) * sanitize (2.1.0) * sass (3.2.19) * sass-rails (4.0.3) * seed-fu (2.3.1) * select2-rails (3.5.2) * semantic-ui-sass (0.16.1.0) * settingslogic (2.0.9) * sidekiq (2.17.0) * simple_oauth (0.1.9) * sinatra (1.4.4) * six (0.2.0) * slack-notifier (0.3.2) * slim (2.0.2) * sprockets (2.11.0) * sprockets-rails (2.1.3) * stamp (0.5.0) * state_machine (1.2.0) * stringex (2.5.1) * temple (0.6.7) * therubyracer (0.12.0) * thor (0.19.1) * thread_safe (0.3.4) * tilt (1.4.1) * timers (1.1.0) * tinder (1.9.3) * treetop (1.4.15) * turbolinks (2.0.0) * twitter-stream (0.1.16) * tzinfo (1.2.1) * uglifier (2.3.2) * underscore-rails (1.4.4) * unicorn (4.6.3) * unicorn-worker-killer (0.4.2) * version_sorter (1.1.0) * virtus (1.0.1) * warden (1.2.3)