Redmine on Dotcloud

ご注意

下記のパスワード、VeryVeryVeryVeryVerySecretPhaseは仮です。ご利用する際はより強固なパスワードをご利用ください。
下記の設定値も適当に設定しております。適宜ご変更願います。

Redmineによるタスクマネジメント実践技法

Redmineによるタスクマネジメント実践技法

手順

  1. dotCloudアカウントの取得
  2. dotcloudコマンドのインストール
  3. デプロイ環境初期化
  4. Redmine環境の設定
  5. Dotcloud環境の構築

1. dotCloudアカウントの取得

1. dotCloutにアクセスして、ページ中の『Sign UP』をクリックします。

2. 画面の内容を確認し、『Sign Up』をクリックしてアカウントを作成します。

3. 右上の『setting』のリンクをクリックします。ユーザの設定の画面が表示されるので、画面上の『API Key』を控えます。

2. dotcloudコマンドのインストール

このぺーじを参考に、インストールします。

$ sudo easy_install pip && sudo pip install dotcloud

3. デプロイ環境初期化

1. 適当なフォルダを作成します。

$ mkdir redmine
$ cd redmine

2. フォルダ内に『dotcloud.yml』を作成します。

$ touch dotcloud.yml

3. 『dotcloud.yml』内の記述を下記を参照に記載します。

redmine:
  type: ruby
  approot: redmine-1.2.1
  config:
    # このように設定すると REE 1.8 シリーズが使われるようです。
    ruby-version: ree
db:
  type: mysql

上記設定の参考はこちら
4. dotCloud上のサービス名を決め、サービスを作成します。
初期のサービス作成の際、dotCloudアカウントの取得で控えた『API Key』の入力が必要になります。
※ 参考にしたこちらのページでは上記サービスをnamespaceと呼んでいます。

$ dotcloud create test
$ dotcloud push test
# upload /home/**********/redmine ssh://dotcloud@uploader.dotcloud.com:**********/test
# rsync
building file list ... done
./
dotcloud.yml

sent 277 bytes  received 34 bytes  88.86 bytes/sec
total size is 185  speedup is 0.59
Deployment for "test" triggered. Will be available in a few seconds.
2011-08-17 14:57:08 [api] Deploy test scheduled for revision=latest
2011-08-17 14:57:08 [api] Waiting for the build. (It may take a few minutes)
2011-08-17 14:57:08 [redmine.0] Deploying...
2011-08-17 14:57:09 [db.0] Deploying...
2011-08-17 14:57:27 [redmine.0] Service booted
2011-08-17 14:57:31 [db.0] Service booted
2011-08-17 14:57:31 [api] All the services are ready. Beginning the build.
2011-08-17 14:57:32 [db.0] The build started
2011-08-17 14:57:32 [db.0] This service type does not support build method, ignoring...
2011-08-17 14:57:32 [db.0] The build finished successfully
2011-08-17 14:57:32 [redmine.0] The build started
2011-08-17 14:57:33 [redmine.0] Fetched code revision rsync-1313593027.81
2011-08-17 14:57:37 [redmine.0] -su: line 0: cd: current: No such file or directory
2011-08-17 14:57:38 [redmine.0] -su: line 0: cd: current: No such file or directory
2011-08-17 14:57:39 [redmine.0] -su: line 0: cd: current: No such file or directory
2011-08-17 14:57:40 [redmine.0] -su: line 0: cd: current: No such file or directory
2011-08-17 14:57:41 [redmine.0] -su: line 0: cd: current: No such file or directory
2011-08-17 14:57:41 [redmine.0] install: cannot create directory `/home/dotcloud/current': File exists
2011-08-17 14:57:42 [redmine.0] nginx start/running, process 1499
2011-08-17 14:57:42 [redmine.0] The build finished successfully
2011-08-17 14:57:42 [api] Deploy finished

Deployment finished. Your application is available at the following URLs
redmine: http://**********.dotcloud.com/

この時、『dotcloud info test』などのサービスのinfoを見るようなコマンドを入力すると、下記の通りにdotCloud環境の設定が出力されるので、控えてください。

$ dotcloud info test.redmine
build_revision: rsync-1313593027.81
cluster: wolverine
config:
    rack-env: production
    ruby-version: ree
created_at: 1313593028.8072541
ports:
-   name: ssh
    url: ssh://dotcloud@**********.dotcloud.com:**********
-   name: http
    url: http://**********.dotcloud.com/
state: running
type: ruby
$ dotcloud info test.db
cluster: wolverine
config:
    mysql_password: **********
created_at: 1313593029.0841889
ports:
-   name: ssh
    url: ssh://mysql@**********.dotcloud.com:**********
-   name: mysql
    url: mysql://root:**********@**********.dotcloud.com:**********
state: running
type: mysql

4. Redmine環境の設定

1. Redmineをダウンロードします。

$ wget http://rubyforge.org/frs/download.php/75097/redmine-1.2.1.tar.gz

2. 展開します。

$ tar xvzf redmine-1.2.1.tar.gz

3. Redmineの設定
redmine/redmine-1.2.1/config/environment.rb

# Be sure to restart your web server when you modify this file.
...
  # 末尾から一行上に下記内容を記載いたします。
  config.action_controller.session = { :key => "_myapp_session", :secret => "VeryVeryVeryVeryVerySecretPhase" }
end

redmine/redmine-1.2.1/config/以下の
database.yml.sampleをdatabase.ymlに複製し、内容を修正します。

# MySQL (default setup).

production:
  adapter: mysql
  database: redmine
  # MySQLのあるホスト名です。
  # デプロイ環境初期化時にDB用として出力されたものを利用します。
  host: **********.dotcloud.com
  # MySQLのあるポート番号です。
  # デプロイ環境初期化時にDB用として出力されたものを利用します。
  port: **********
  # MySQLの初期化時に作成するMySQL用ユーザです。
  username: redmine
  # MySQLの初期化時に使用するパスワードです。
  password: passwd1234
  encoding: utf8

5. dotCloud環境の構築

1. MySQLの初期化
デプロイ環境初期化より、MySQLの接続設定を参考にします。
パスワードはデプロイ環境初期化を参考にします。
grantで用いるホスト名はtest.redmineのものを利用します。

$ dotcloud ssh test.db
$ mysql -u root -p
Enter password:
sql> create database redmine character set utf8 ;
sql> grant all on redmine.* to redmine@"%" identified by "passwd1234" ;
sql> quit
$ exit

2. Rubyの設定
環境には、必要なgemsがそろっていないのでインストールします。

$ dotcloud ssh test.redmine
$ gem install mysql   --no-ri --no-rdoc
$ gem install rack    --no-ri --no-rdoc -v=1.1.1
$ gem install i18n    --no-ri --no-rdoc -v=0.4.2
$ exit

2. Redmineのデプロイ
最終的に、最終行で出てくるURLでredmineにアクセスできるようになります。
共有SSLがあるので、httpsでも接続できます。

$ dotcloud push test .
...
Deployment finished. Your application is available at the following URLs
redmine: http://**********.dotcloud.com/

3. DBの初期化
rake redmine:load_default_dataにて、jaを選択します。

$ dotcloud ssh test.redmine
$ cd current
$ rake db:migrate RAILS_ENV=production
...
$ rake redmine:load_default_data
(in /home/dotcloud/rsync-1313595382.12/redmine-1.2.1)

Select language: bg, bs, ca, cs, da, de, el, en, en-GB, es, 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, sr, sr-YU, sv, th, tr, uk, vi, zh, zh-TW [en] ja
====================================
Default configuration data loaded.
$ exit

4. 完了です。お疲れ様でした。

結論

  • 動くし、共有SSLあるよ。
  • VPSよりお手軽です!
  • もっさりー。