Heroku command summary

Introduction

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.

Why use Heroku

It usually takes a lot of time and money to deploy, but Heroku is basically free and requires less deployment.

Contents to summarize

-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

Heroku installation command

command

 brew tap heroku/brew && brew install heroku

Check version command

 heroku --version

Login command

#Login command
heroku login

If the following display appears, login is successful.

Logged in as [email protected]

Application creation command

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

Commands that can use MySQL

Heroku defaults to a database called PostgreSQL. You can set it by adding the ClearDB add-on.

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.

Manage encrypted values

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.

Environment variable

Encrypted data can be set in environment variables.

Environment variable reference command

heroku config

Add environment variable command

heroku config:set environment variable name="value"

ex)heroku config:set RAILS_MASTER_KEY=`cat config/master.key`

Delete environment variables

heroku config:unset environment variable name

Deploy on Heroku

command

git push heroku master

Executing the migration file

command

heroku run rails db:migrate

Check the information of the published application

command

heroku apps:info

Open the app on your browser

heroku open

Post-deployment error

Check the log to find the cause.

heroku logs

Check the last log

heroku logs --tail

Referenced page

[Super Introduction] How to use Heroku starting from the basics (for beginners)

Recommended Posts

Heroku command summary
Docker command summary
[Docker] Command summary
[Rails] Migration command summary
Heroku CLI operation (command)
[Rails] rails db command summary
docker command personal summary
Summary
Object-oriented summary
Command Pattern
heroku deploy
[Rails Struggle/Rails Tutorial] Summary of Heroku commands
Error when trying to use heroku command
Docker command
ransack summary
Command docker-compose
A note when the heroku command becomes unavailable