👇前回の記事はこちら
Herokuの登録&デプロイの準備(DB設定、Gitとのコネクト)
①Herokuのホームページにアクセスし、『無料で新規登録』をクリック
(既に登録済みの方はそのままログイン)

②記入項目を埋めて『無料アカウント作成』をクリック

③メールでの確認を承認した後、ログイン状態になる。
デプロイに必要になるHeroku側のアプリを作成するため、『Create new app』をクリック

④Appnameはご自身の好きな名前(私は「pankun-product-register」にしました)、
regionは「United Dtates」を選択し『Create app』をクリック

⑤デプロイする用のアプリができました。次に、本番環境ではコンテナに用意したDB(postgres)だとうまく機能しないので、Heroku側で用意されているPostgresに設定します。
タグのResourcesをクリックします。

⑥検索バーに「postgres」と入力し、Heroku Postgresを選択

⑦Plan nameが「Hobby Dev – Free」となっていることを確認し、『Submit Order Form』をクリック

⑧赤枠のように選択したサービスなっていればOK

👇Config Vars(DBのキー)を設定していきます。タグのSettingをクリックし
KEYに『SECRET_KEY_BASE』、VALUEにproduct-register/config/master.keyに
記載のある文字列を入力。最後に「ADD」をクリック

👇Rails側のDBの設定も変更します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<~/desktop/product-register/config/database.yml> 〜〜〜省略〜〜〜 # You can use this database configuration with: =================有効にする=================== production: url: <%= ENV['DATABASE_URL'] %> ========================================= ======================コメントアウト======================= # production: # <<: *default # database: product-register_production # username: product-register # password: <%= ENV['PRODUCT-REGISTER_DATABASE_PASSWORD'] %> ======================================================= |
👇次に、Deploy時の設定でGitと連携をしていこう
①「Deploy」のタグをクリックし、GitHub、『Connect to GitHub』をクリック

②「Authorize Heroku」をクリック

③検索バーでSearchし、「product-regigter」を選択し『Connect』をクリック

④Automatic Deploysの「Wait for CI to pass before deploy 」にチェックを入れ、
『Enable Automatic Deploys』をクリック

これで、デプロイの準備以上になります。
次回は.travis.ymlにHerokuへデプロイするための記述を追加していきます。
今回はこの辺で、ばいばい👋
コメントを残す