BlueMix は cloudfoundry 互換なので cf コマンドで操作する。
cf をインストール
gem install cf
target を設定
$ cf target https://api.ng.bluemix.net
Setting target to https://api.ng.bluemix.net... OK
ログイン
$ cf login
target: https://api.ng.bluemix.net
Email> メールアドレス
Password> ************
Authenticating... OK
go のコードを書く
簡単なやつ
package main
import (
"net/http"
"os"
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello World"))
})
http.ListenAndServe(":"+port, nil)
}
.godir を作る
$ echo server > .godir
Procfile を作る
$ echo "web: server" > Procfile
ビルドパックを指定して push する
$ cf push --name mattn --buildpack https://github.com/michaljemala/cloudfoundry-buildpack-go.git
Instances> 1
1: 128M
2: 256M
3: 512M
4: 1G
Memory Limit> 256M
Creating mattn... OK
1: mattn
2: none
Subdomain> mattn
1: ng.bluemix.net
2: none
Domain> ng.bluemix.net
Creating route mattn.ng.bluemix.net... OK
Binding mattn.ng.bluemix.net to mattn... OK
Preparing to start mattn... OK
Checking status of app 'mattn'...
1 of 1 instances running (1 running)
Push successful! App 'mattn' available at mattn.ng.bluemix.net
ソースはここに置いておきます。