Rhythm & Biology

Engineering, Science, et al.

dotcloud

dotcloudのinvitationをもらったので早速動かしてみました。

まずは準備

% sudo easy_install dotcloud
% dotcloud create mythosil
% dotcloud deploy -t perl mythosil.www

Hello Worldを出すだけの簡単なpsgi

# app.psgi
use strict;
use warnings;
use Plack::Request;

return sub {
  my $env = shift;
  my $req = Plack::Request->new($env);
  my $res = $req->new_response(200);
  $res->content_type("text/html");
  $res->body(<<EOM);
<html>
<head>
<title>in the mythosil</title>
</head>
<body>
Hello World
</body>
</html>
EOM
  return $res->finalize;
};

cpanのモジュールを使う場合、依存関係を明示

# Makefile.PL
use inc::Module::Install;
name 'mythosil-dotcloud';
version '0.01';
license 'perl';
requires 'Plack::Request' => 0;
WriteAll;

Makefileの作成

% perl Makefile.PL

git commitしたものだけがアップロードされるということなので、gitのセットアップ

% git init
% git add .
% git commit -a

最後にpushします。この時に、Makefile.PLに書いておいた依存モジュールを自動でcpanからインストールしてくれます。

% dotcloud push mythosil.www .

あとはブラウザで確認。
動かし方が分かったので、次は何を試そうか企み中です。