herokuセットアップ、sinatraを動かす
herokuでsinatra動かした。
参考にした
サインアップ
https://heroku.com でサインアップ、メールが来るのでconfirm
アプリを作る
普通のsinatraアプリを作ってみる。
% ls Gemfile Gemfile.lock Procfile web.rb
の4つのファイルが最終的にできる。
web.rb
require 'rubygems' require 'sinatra' get '/' do 'hello work' end
Gemfile
source :rubygems gem 'sinatra' gem 'thin'
Procfile を作る。中身はこれ
web: bundle exec ruby web.rb -p $PORT
config.ruを使うならこうらしい
web: bundle exec rackup config.ru -p $PORT
ローカルで動かしてみる
Procfileで動かすためにforemanってのを使うらしい。
gem install foreman bundle install foreman start
herokuにデプロイ
gitリポジトリにしてherokuにpushする。
git init git add Gemfile Gemfile.lock web.rb Procfile git commit -m 'first commit'
Gemfile.lockもcommitする。
heroku create --stack cedar git push heroku master
remoteにherokuが追加されているので、pushする
herokuで動いた
http://simple-mountain-9295.herokuapp.com みたいな長い名前で起動するので、 https://api.heroku.com/myapps/ で名前を変更した。
こうなった。
http://shokai.herokuapp.com/