Keep a note of how to deploy.
Proceed with the prerequisite that your app has been merged into master on GitHub.
First, use a service called Heroku Heroku new registration page https://signup.heroku.com/login
If you enter the required items here, you will receive an email, so enter it and enter the following! * Enter at least 8 characters including alphanumeric characters, numbers, and symbols.
Registration is complete when something like this comes out ⬇︎
When the screen below appears, click "Accept" at the bottom of the screen ⬇︎
If you can go to the top screen of Heroku, k⬇︎
Credit card registration is required to use MySQL on Heroku, so register your card information from Billing on the account management page.
Follow the screenshot steps below
Enter your credit card information
Registration is complete when the screen below appears!
Please change to the directory you want to upload to Heroku before installing. This time I will explain in the procedure to upload the project directory
Terminal
% brew tap heroku/brew && brew install heroku
Heroku version confirmation command ↓
% heroku --version
heroku/7.40.0 darwin-x64 node-v12.16.2 #If such a guy comes out, k
#Command to log in to Heroku
% heroku login --interactive
=> Enter your Heroku credentials.
#Enter your email address and press enter
=> Email:
#Enter your password and press enter
=> Password:
%heroku create app name
Command to check if it was done properly ⬇︎
% git config --list | grep heroku
If anything other than fatal: not in a git directory is displayed, proceed to the next step.
% heroku addons:add cleardb
I added an add-on, but I haven't set it yet, so execute the following command
% heroku_cleardb=`heroku config:get CLEARDB_DATABASE_URL`
You have now stored the URL of your ClearDB database in the variable heroku_cleardb.
% heroku config:set DATABASE_URL=mysql2${heroku_cleardb:5}
You have now reset the database URL. AjaxApp uses a gem called mysql2, so make sure that the beginning of the DATABASE_URL has been changed to mysql2: //.
Terminal
% EDITOR="vi" bin/rails credentials:edit
If you see a screen like the one below After confirming, enter "esc key"-> ":"-> "q" and press "enter key" to close credentials.yml.enc.
It is used to refer to, add, and delete environment variables on Heroku. To add an environment variable, run heroku config: set environment variable name = "value" . By doing so, you can add environment variables on Heroku.
Execute the following command in the terminal
Terminal
% heroku config:set RAILS_MASTER_KEY=`cat config/master.key`
% heroku config
If it looks like the following
Terminal
% heroku stack:set heroku-18 -a application name
Terminal
% git push heroku master
If the push is successful, execute the migration with the following command
Terminal
% heroku run rails db:migrate
Terminal
% heroku apps:info
After executing with the above command, in that item Web URL: https: // .... App URL
Because there is, it becomes the URL published on the WEB
Run the following command to get a hint
Terminal
% heroku logs --tail --app app name
You can also check with the "heroku logs app name" command, but by using the "--tail" option, only the latest 10 lines of logs will be displayed.
Login command
Terminal
% heroku login --interactive
Created on Heroku
Terminal
%heroku create app name
Add ClearDB add-on
Terminal
% heroku addons:add cleardb
Change settings
Terminal
% heroku_cleardb=`heroku config:get CLEARDB_DATABASE_URL`
Database reconfiguration
Terminal
% heroku config:set DATABASE_URL=mysql2${heroku_cleardb:5}
Check the contents, after checking, enter "esc key" → ":" → "q" and press "enter key"
Terminal
% EDITOR="vi" bin/rails credentials:edit
Setting environment variables
Terminal
% heroku config:set RAILS_MASTER_KEY=`cat config/master.key`
App push
Terminal
% heroku stack:set heroku-18 -a application name
Terminal
% git push heroku master
Perform migration
Terminal
% heroku run rails db:migrate
Check settings
Terminal
% heroku apps:info
Thank you for watching till the end! I hope it helps someone!
Recommended Posts