0
1

More than 3 years have passed since last update.

Herokuへのデプロイ【Ruby on Rails】初心者

Last updated at Posted at 2020-10-15

開発環境:macOS Catalina/GitHub/MySQL

※Herokuへのユーザー登録完了後の手順です。
備忘録として残したいと思い、記事にしました。
初心者なので、至らない点があるかと思いますがその際はコメントいただけたらと思います。

1. Heroku CLIをインストールする

コマンド

% brew tap heroku/brew && brew install heroku

バージョンの確認

% heroku --version

バージョンが出力されたらインストール完了

公式サイト:https://devcenter.heroku.com/articles/heroku-cli

2. ログインする

% heroku login --interactive
  Email: それぞれ入力
  password: それぞれ入力

:information_desk_person:登録したメールアドレスがLogged in asの後に表示されていればログイン成功

3. Gemの導入

Gemfile ※一番下に入力

Gemfile
group :production do
   gem 'rails_12factor'
end

:information_desk_person:bundle installと再起動をお忘れなく

:information_desk_person:Gitで管理している場合はコミットしておきます

4. Heroku上にアプリケーションを作成する

% heroku create [アプリケーション名]
% git config --list | grep heroku

:information_desk_person:この時、"fatal: not in a git directory"以外が出力されていれば作成完了です!

5. MySQLを使えるようにするコマンド

% heroku addons:add cleardb
% heroku_cleardb=`heroku config:get CLEARDB_DATABASE_URL`
% heroku config:set DATABASE_URL=mysql2${heroku_cleardb:5}

:information_desk_person:URLの"mysql2"はGemの使用状況によって変更する
以降は非公開の値を管理する為の環境変数の設定などを行います。

6. 公開を確認するコマンド

% heroku apps:info

参考:https://devcenter.heroku.com/articles/getting-started-with-rails6

0
1
1

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
1