I created this article because I thought it would be useful to put together the commands. Also, as a prerequisite, you have created a Heroku account.
It usually takes a lot of time and money to deploy, but Heroku is basically free and requires less deployment.
-Heroku installation command ・ Login command -Application creation command -Commands that can use MySQL -Management of encrypted values ・ Deploy on Heroku -Execute the migration file ・ Confirmation of published application -Error after deployment
command
brew tap heroku/brew && brew install heroku
Check version command
heroku --version
#Login command
heroku login
If the following display appears, login is successful.
Logged in as [email protected]
command
heroku create application name
If the application is created successfully, the following will be displayed.
Creating app... done,⬢ Application name
https://Application name.herokuapp.com/ | https://git.heroku.com/Application name.git
Heroku defaults to a database called PostgreSQL. You can set it by adding the ClearDB add-on.
Commands that can configure MySQL Enter the command as below
heroku addons:add cleardb
Next, enter the following command to use the gem corresponding to MySQL
heroku_cleardb=`heroku config:get CLEARDB_DATABASE_URL`
Enter the following
heroku config:set DATABASE_URL=mysql2${heroku_cleardb:5}
Now you can reset the URL.
credentials.yml.enc File used to encrypt information master.key Key role for decrypting credentials.yml.enc
If this is left as it is, master.key is not managed due to the default mechanism of Git, so it cannot be deployed.
Encrypted data can be set in environment variables.
heroku config
heroku config:set environment variable name="value"
ex)heroku config:set RAILS_MASTER_KEY=`cat config/master.key`
heroku config:unset environment variable name
command
git push heroku master
command
heroku run rails db:migrate
command
heroku apps:info
heroku open
Check the log to find the cause.
heroku logs
Check the last log
heroku logs --tail
[Super Introduction] How to use Heroku starting from the basics (for beginners)
Recommended Posts