オープンソースのPaaSソフトウェア CloudFoundry の技術情報やイベント告知などを掲載します

2015-09-15

PasswordPusher を Cloud Foundry で動かす

「Cloud Foundry 百日行」第61日目は、Ruby-on-Rails ベースの PasswordPusher です。このアプリは、何かのパスワードを遠隔で共有したい場合、Web上で比較的セキュアに簡単に共有することができます。

基本情報

デプロイ準備から動作確認までの手順は以下の通りです。

  • 1) ソースコードの取得
  • 2) デプロイ
  • 3) 動作確認

1. ソースコードの取得

GitHub からソースコードをクローンします。

$ git clone https://github.com/pglombardo/PasswordPusher.git
$ cd PasswordPusher
PasswordPusher$ ls
app       bin      config     db       Gemfile.lock  log       public    README.md  TODO
app.json  Capfile  config.ru  Gemfile  LICENSE.txt   Procfile  Rakefile  script

2. デプロイ

アプリの ReadMe にも database.yml にも書いてありませんが、 Gemfile の中を確認すると production 指定でデプロイしたい場合、 PostgreSQL を使うことを想定しているようです。
なので、まず PostgreSQL のサービスを作成します。 もしデプロイする bosh-lite 環境に PostgreSQL サービスブローカがない場合、 百日行の「postgresql-cf-service-broker を Cloud Foundry で動かす 」を参考に、事前に準備をしてください。

PasswordPusher$ cf create-service PostgreSQL 'Basic PostgreSQL Plan' spwd-pg
Creating service instance spwd-pg in org horiu-jn / space horiu-jn as horiu-jn...
OK

Attention: The plan `Basic PostgreSQL Plan` of service `PostgreSQL` is not free.  The instance `spwd-pg` will incur a cost.  Contact your administrator if you think this is in error.

次に、デプロイ用のマニフェストを作成します。

PasswordPusher$ vi manifest.yml
applications:
- name: spwd-100
  command: 'RAILS_ENV=production bundle exec rake db:setup && bundle exec rackup --port $PORT'
  services:
    - spwd-pg
  • services: にバインドするサービス名を記述しておくと、 cf push した際に自動でバインドを実行してくれるため、設定しておきます。

マニフェストが作成できたら、アプリをプッシュします。

PasswordPusher$ cf push
Using manifest file /home/horiu-jn/workspace/apps/PasswordPusher/manifest.yml

Creating app spwd-100 in org horiu-jn / space horiu-jn as horiu-jn...
OK

Using route spwd-100.10.244.0.34.xip.io
Binding spwd-100.10.244.0.34.xip.io to spwd-100...
OK

Uploading spwd-100...

:

0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
1 of 1 instances running

App started


OK

App spwd-100 was started using this command `RAILS_ENV=production bundle exec rake db:setup && bundle exec rackup --port $PORT`

Showing health and status for app spwd-100 in org horiu-jn / space horiu-jn as horiu-jn...
OK

requested state: started
instances: 1/1
usage: 256M x 1 instances
urls: spwd-100.10.244.0.34.xip.io
last uploaded: Thu Aug 13 07:18:12 UTC 2015
stack: cflinuxfs2
buildpack: Ruby

     state     since                    cpu    memory           disk      details
#0   running   2015-08-13 04:20:53 PM   0.0%   179.7M of 256M   0 of 1G

無事成功しました。

3. 動作確認

ブラウザから、払いだされたアプリのURLへアクセスします。

Enter the Password to be Shared と表示されているフィールドへ、共有したいパスワードを入力します。
パスワードの共有リミットを期間 (Days) またはアクセス回数 (Views) を設定することも出来ます。

パスワードを入力したあと Push it! ボタンを押すと、ランダムな文字列で作成された共有用の URL が表示されます。

この URL へアクセスしてみると、先ほど登録したパスワードが表示されます。

また、設定したURLへのアクセス回数、または共有期間を超えると、パスワードは失効となります。

今回使用したソフトウェア



投稿者:NTTソフトウェア株式会社 堀内 純