matsumotory氏のmruby-simplehttpserverをcapstanを使ってお手軽簡単にOSv向けにビルド&実行する
OSvは最近capstanというビルド・デプロイツールが出来たので、以前のようにOSをビルドしなくてもアプリだけビルドしてVMイメージ作成&実行が簡単にできます。
ここでは、@matsumotory氏がブログで解説されていたmruby-simplehttpserver用のcapstanリポジトリを作成してみたので、インストール&実行方法を紹介します。
バイナリディストリビューションのインストール&実行はWindows・Mac・Linuxに対応していますが、今のところソースコードからアプリをビルドするにはLinuxが必要(公式対応ディストリはFedora 20)なので、以下の手順はFedora 20を使って説明します。
なお、この記事ではcapstan用リポジトリの作り方について詳しい解説をしていませんが、こちらにビルド設定定義ファイル「Capstanfile」のドキュメントがあるので、興味があれば読んでみて下さい。
GoとQEMUとgitをインストール
wget http://go.googlecode.com/files/go1.2.1.linux-amd64.tar.gz sudo tar -C /usr/local -xzf go1.2.1.linux-amd64.tar.gz sudo yum install qemu-system-x86 git
.bashrcに環境変数を追加
export GOROOT=/usr/local/go export GOPATH=$HOME/go export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
capstanをインストール
go get github.com/cloudius-systems/capstan
mruby-simplehttpserver用のcapstanリポジトリをチェックアウト
git clone https://github.com/syuu1228/capstan-mruby-simplehttpserver.git
リポジトリのビルド
cd capstan-mruby-simplehttpserver
capstan build
http serverへのアクセステスト
curl http://127.0.0.1:10080/html -v * About to connect() to 127.0.0.1 port 10080 (#0) * Trying 127.0.0.1... * Adding handle: conn: 0xd0d8f0 * Adding handle: send: 0 * Adding handle: recv: 0 * Curl_addHandleToPipeline: length: 1 * - Conn 0 (0xd0d8f0) send_pipe: 1, recv_pipe: 0 * Connected to 127.0.0.1 (127.0.0.1) port 10080 (#0) > GET /html HTTP/1.1 > User-Agent: curl/7.32.0 > Host: 127.0.0.1:10080 > Accept: */* > * HTTP 1.0, assume close after body < HTTP/1.0 200 OK < Server: my-mruby-simplehttpserver < Date: Mon, 19 May 2014 17:57:13 GMT < Content-Type: text/html; charset=utf-8 < Content-Length: 28 < <H1>Hello mruby World.</H1> * Closing connection 0