[!NOTE]
この記事は 2013/04/08 に momoto.github.io へ投稿した内容を Qiita へ移行してきたものです
Heroku が提供する PaaS にプロジェクト管理ソフトウェア Redmine 2.3 を展開します。 Redmine のバージョンは 2.3、Ruby は 1.9.2-p320、heroku-toolbelt は 2.39.4 を使用しています。
1. Redmine 2.3 のダウンロード
2013/05/31 の時点で最新版である 2.3 を Git でクローンします。
$ git clone git://github.com/redmine/redmine.git -b 2.3-stable
Cloning into 'redmine'...
$ cd redmine
2. Ruby の確認および bundler のインストール
ここでは Ruby のバージョン管理に rbenv
を使用しています。また、インストールの過程で bundler
が必要になります。
$ rbenv local 1.9.2-p320
$ ruby --version
ruby 1.9.2p320 (2012-04-20 revision 35421) [x86_64-linux]
$ gem install bundler
Successfully installed bundler-1.3.5
1 gem installed
Installing ri documentation for bundler-1.3.5...
Building YARD (yri) index for bundler-1.3.5...
Installing RDoc documentation for bundler-1.3.5...
3. gitignoreの編集
.gitignore
から次の記述を削除します。セキュリティの理由から config/initializers/secret_token.rb
等は Git リポジトリに含めないことが望ましく、デプロイタスクの中で工夫があるとよいのですが、本稿ではそこまで検証が及んでいません。
-/config/configuration.yml
-/config/email.yml
-/config/initializers/session_store.rb
-/config/initializers/secret_token.rb
-/public/plugin_assets
-/Gemfile.lock
-/Gemfile.local
4. Gemfile の編集
次のように書き換えました。
source 'https://rubygems.org'
gem "rails", "3.2.13"
gem "jquery-rails", "~> 2.0.2"
gem "i18n", "~> 0.6.0"
gem "coderay", "~> 1.0.6"
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
gem "builder", "3.0.0"
group :ldap do
gem "net-ldap", "~> 0.3.1"
end
group :openid do
gem "ruby-openid", "~> 2.1.4", :require => "openid"
gem "rack-openid"
end
platforms :mri, :mingw do
group :rmagick do
gem "rmagick", ">= 2.0.0"
end
end
platforms :mri, :mingw do
group :postgresql do
gem "pg", ">= 0.11.0"
end
end
platforms :jruby do
gem "jruby-openssl"
group :postgresql do
gem "activerecord-jdbcpostgresql-adapter"
end
end
group :development do
gem "rdoc", ">= 2.4.2"
gem "yard"
end
group :test do
gem "shoulda", "~> 3.3.2"
gem "mocha", ">= 0.14", :require => 'mocha/api'
if RUBY_VERSION >= '1.9.3'
gem "capybara", "~> 2.1.0"
gem "selenium-webdriver"
end
end
local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
if File.exists?(local_gemfile)
puts "Loading Gemfile.local ..." if $DEBUG # `ruby -d` or `bundle -v`
instance_eval File.read(local_gemfile)
end
# Load plugins' Gemfiles
Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file|
puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
#TODO: switch to "eval_gemfile file" when bundler >= 1.2.0 will be required (rails 4)
instance_eval File.read(file), file
end
5. config/application.rb の編集
次の記述を追記しました。
+ config.assets.initialize_on_precompile = false
6. config/environment.rb の編集
次の記述をコメントアウトします。
-vendor_plugins_dir = File.join(Rails.root, "vendor", "plugins")
-if Dir.glob(File.join(vendor_plugins_dir, "*")).any?
- $stderr.puts "Plugins in vendor/plugins (#{vendor_plugins_dir}) are no longer allowed. " +
- "Please, put your Redmine plugins in the `plugins` directory at the root of your " +
- "Redmine directory (#{File.join(Rails.root, "plugins")})"
- exit 1
-end
+#vendor_plugins_dir = File.join(Rails.root, "vendor", "plugins")
+#if Dir.glob(File.join(vendor_plugins_dir, "*")).any?
+# $stderr.puts "Plugins in vendor/plugins (#{vendor_plugins_dir}) are no longer allowed. " +
+# "Please, put your Redmine plugins in the `plugins` directory at the root of your " +
+# "Redmine directory (#{File.join(Rails.root, "plugins")})"
+# exit 1
+#end
7. Gemパッケージのインストール
bundle
コマンドで、必要な Gem パッケージをインストールします。
$ bundle install --without production test
Fetching gem metadata from https://rubygems.org/.........
...
Your bundle is complete!
8. セッションストアの生成
$ bundle exec rake generate_secret_token
9. アプリケーションの作成
Heroku ツールベルトを使用して、アプリケーションを作成します。ツールベルトと同様に、Heroku アカウントの登録が必要です。
$ heroku login
Enter your Heroku credentials.
Email: ********
Password (typing will be hidden):
Authentication successful.
$ heroku create [NAME]
Creating [NAME]... done, stack is cedar
http://[NAME].herokuapp.com/ | git@heroku.com:[NAME].git
Git remote heroku added
10. Heroku へデプロイ
Git を使用します。Pushの時点で config/database.yml が自動的に作られるようです。
$ git add .
$ git commit -m "init"
$ git push heroku 2.3-stable:master
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.3.2
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
-----> Launching... done, v8
11. テーブルやデフォルトデータの用意
言語を選択するプロンプトが現れます。
$ heroku run rake db:migrate
Connecting to database specified by DATABASE_URL
Creating scope :system. Overwriting existing method Enumeration.system.
...
$ heroku run rake redmine:load_default_data
Connecting to database specified by DATABASE_URL
Creating scope :system. Overwriting existing method Enumeration.system.
Select language: ar, az, bg, bs, ca, cs, da, de, el, en, en-GB, es, et, eu, fa, fi, fr, gl, he, hr, hu, id, it, ja, ko, lt, lv, mk, mn, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sq, sr, sr-YU, sv, th, tr, uk, vi, zh, zh-TW [en] ja
====================================
Default configuration data loaded.
12. 動作確認
Heroku のアプリケーション URL へアクセスして動作を確認します。