ゴール
- 前回のエントリでは、PaaSの代表格であるHerokuをとりあえず使ってみた
- 今回はHerokuでGo言語製ウェブフレームワークのひとつであるRevelを動かしたい
- 番外「サブドメインをかっちょよくしたい」
記録
とりあえず新しいRevelプロジェクトつくる
% revel new myapp % cd $GOPATH/src/myapp
gitリポジトリにする
% git status fatal: Not a git repository (or any of the parent directories): .git % git init # なにかmodifyしたかったらここで何かして... % git add . % git commit -m "Initial commit だよーん"
RevelをHerokuで動かす用のBuildPackを指定しつつ、herokuインスタンスを確保する(ちなみにこれrobfig*1謹製)
% heroku create -b https://github.com/robfig/heroku-buildpack-go-revel.git Creating limitless-depths-8649... done, stack is cedar BUILDPACK_URL=https://github.com/robfig/heroku-buildpack-go-revel.git http://limitless-depths-8649.herokuapp.com/ | git@heroku.com:limitless-depths-8649.git Git remote heroku added
git remote
に確保したインスタンスがheroku
の名前でadd
されていることを確認
% git remote -v heroku git@heroku.com:limitless-depths-8649.git (fetch) heroku git@heroku.com:limitless-depths-8649.git (push)
このインスタンスにコードをデプロイする
% git push heroku master Initializing repository, done. Counting objects: 41, done. Delta compression using up to 4 threads. Compressing objects: 100% (32/32), done. Writing objects: 100% (41/41), 79.76 KiB | 0 bytes/s, done. Total 41 (delta 4), reused 0 (delta 0) -----> Fetching custom git buildpack... done Initial commit だよーん -----> Revel app detected -----> Installing Go 1.1.2... done Installing Virtualenv... done Installing Mercurial... done Installing Bazaar... done -----> Running: go get -tags heroku ./... -----> Discovering process types Procfile declares types -> (none) Default types for Revel -> web -----> Compressing... done, 48.1MB -----> Launching... done, v5 http://limitless-depths-8649.herokuapp.com/ deployed to Heroku To git@heroku.com:limitless-depths-8649.git * [new branch] master -> master
と、こうなる
It works!
番外: サブドメインをかっちょよくしたい
どうせなら、自動で割り当てられるダサい名前じゃなくて、tainaka.herokuapp.com
とかにしたいじゃないですかー
heroku.comのダッシュボードのアプリ設定から、Nameを変更する
確保したインスタンスの名前が変わっているはずなので、git remote
で登録されているheroku
の向き先を変える必要がある
% git remote -v heroku git@heroku.com:limitless-depths-8649.git (fetch) heroku git@heroku.com:limitless-depths-8649.git (push) % git remote rm heroku % heroku git:remote -a tainaka Git remote heroku added % git remote -v heroku git@heroku.com:tainaka.git (fetch) heroku git@heroku.com:tainaka.git (push)
あらためてここに向けてデプロイする
% git push heroku master
そうすっと、
tainaka.herokuapp.com
でアプリが動いている
Thanks to id:nekova
いろいろつまずいたポイントをだらだらと
% heroku create
- loginを求められる. PW忘れた. 泣く
- PW更新した
% heroku create ! You\'ve reached the limit of 5 apps for unverified accounts. ! Add a credit card to verify your account.
- 5つまでと怒られる. 泣く
- 怒りの全削除
% heroku create -b https://github.com/robfig/heroku-buildpack-go-revel.git
http://immense-island-8507.herokuapp.com/ | git@heroku.com:immense-island-8507.git
Git remote heroku added
- いけた
% git push heroku master Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
- Permissionが無いと怒られる.
- heroku.comでssh keyを登録する
git push heroku master
! No such app as immense-island-8507.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
- そんなアプリ無ぇと怒られる
- heroku.comでつくったやつ削除
git remote rm heroku
たぶんこれが前のcreateしたときのままだったんだと思う
% git push heroku master
- いけた
雑感
食わず嫌いで苦手意識のあったherokuだけど、理解してしまえば単なるgitリポジトリのhostとアプリのビルドだけっぽいし、今後活用していきたい。自鯖でけっこうメモリ食ってるアプリケーションを引っ越ししたいんだけど、サーバスペックとかどうやって確認したらいいんだろう
DRYな備忘録
プロフェッショナルのための 実践Heroku入門 プラットフォーム・クラウドを活用したアプリケーション開発と運用 (書籍)
- 作者: 相澤歩,arton,鳥井雪,織田敬子
- 出版社/メーカー: KADOKAWA/アスキー・メディアワークス
- 発売日: 2014/09/19
- メディア: 大型本
- この商品を含むブログ (3件) を見る
クラウド開発徹底攻略 (WEB+DB PRESS plus)
- 作者: 菅原元気,磯辺和彦,山口与力,澤登亨彦,内田誠悟,小林明大,石村真吾,相澤歩,柴田博志,伊藤直也,登尾徳誠,WEB+DB PRESS編集部
- 出版社/メーカー: 技術評論社
- 発売日: 2016/05/13
- メディア: 大型本
- この商品を含むブログを見る
プログラミング言語Go (ADDISON-WESLEY PROFESSIONAL COMPUTING SERIES)
- 作者: Alan A.A. Donovan,Brian W. Kernighan,柴田芳樹
- 出版社/メーカー: 丸善出版
- 発売日: 2016/06/20
- メディア: 単行本(ソフトカバー)
- この商品を含むブログ (2件) を見る