LoginSignup
0
0

More than 3 years have passed since last update.

Herokuへデプロイする手順

Last updated at Posted at 2020-10-26

Herokuへデプロイする手順

ターミナル
brew tap heroku/brew && brew install heroku
ターミナル
heroku --version
ターミナル
# Herokuへログインするためのコマンド
% heroku login --interactive
  => Enter your Heroku credentials.
# メールアドレスを入力しエンターキーを押す
  => Email:
# パスワードを入力してエンターキーを押す
  => Password:
Gemfile
# ファイルの一番下の行に追記する
group :production do
  gem 'rails_12factor'
end
ターミナル
# Gemをインストール
% bundle install
ターミナル
% git add .
% git commit -m "gem rails_12factorの追加"
ターミナル
% heroku create アプリケーション名
ターミナル
% git config --list | grep heroku
ターミナル
% heroku addons:add cleardb
Creating cleardb on  アプリケーション名... free
Created cleardb-vertical-00000 as CLEARDB_DATABASE_URL
Use heroku addons:docs cleardb to view documentation
ターミナル
% heroku_cleardb=`heroku config:get CLEARDB_DATABASE_URL`
ターミナル
% heroku config:set DATABASE_URL=mysql2${heroku_cleardb:5}

# 以下コマンドの実行結果
Setting DATABASE_URL and restarting  アプリケーション名... done, v◯◯
DATABASE_URL: mysql2://000000000000:0aa0000@us-cdbr-east-02.cleardb.com/heroku_aaa00000000?reconnect=true
ターミナル
% EDITOR="vi" bin/rails credentials:edit
ターミナル
% heroku config:set RAILS_MASTER_KEY=`cat config/master.key`
ターミナル
% heroku config
ターミナル
% git push heroku master
ターミナル
% heroku run rails db:migrate

公開を確認

ターミナル
% heroku apps:info

===ajax-app-123456
Addons:         cleardb:ignite
Auto Cert Mgmt: false
Dynos:          web: 1
Git URL:        https://git.heroku.com/アプリケーション名.git
Owner:          sample@sample.com
Region:         us
Repo Size:      165 KB
Slug Size:      56 MB
Stack:          heroku-18
Web URL:        https:/アプリケーション名.herokuapp.com/

現場からは以上です!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0