How to deploy

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.

スクリーンショット 2021-01-16 18.57.07.png

Registration is complete when something like this comes out ⬇︎

スクリーンショット 2021-01-16 18.59.44.png

When the screen below appears, click "Accept" at the bottom of the screen ⬇︎

スクリーンショット 2021-01-16 19.00.47.png

If you can go to the top screen of Heroku, k⬇︎

スクリーンショット 2021-01-16 19.01.59.png

Heroku notes

Heroku is basically free to use, but the database settings used are RDBMS called PostgreSQL by default.

Credit card registration is required to use MySQL on Heroku, so register your card information from Billing on the account management page.

Credit card registration

I used MySQL so I will register my credit card (skip if you don't)

Follow the screenshot steps below

スクリーンショット 2021-01-16 19.05.57.png

スクリーンショット 2021-01-16 19.06.09.png

スクリーンショット 2021-01-16 19.06.17.png

Enter your credit card information

スクリーンショット 2021-01-16 19.06.23.png

Registration is complete when the screen below appears!

スクリーンショット 2021-01-16 19.06.31.png

Install Heroku CLI

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 command

%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.

Add ClearDB add-on

The ClearDB add-on is a tool for using MySQL. It's an add-on provided by a database service called ClearDB, and by adding it, you can use MySQL on Heroku.
% heroku addons:add cleardb

Change settings

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: //.

Check the contents of credentials.yml.enc

Execute the following command to check the contents

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.

スクリーンショット 2021-01-17 2.16.27.png

Environment variable settings

heroku config command

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

スクリーンショット 2021-01-17 2.49.07.png

Push application

Push the application by executing the following two commands

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

Confirmation of publication

You can check various settings with the following command

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

If you access the URL and get an error (sweat

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.

No commentary required! Nah, a summary of only the commands for impatient

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

How to deploy
How to deploy on heroku
How to deploy jQuery on Rails
How to deploy Laravel on CentOS 7
How to develop OpenSPIFe
How to call AmazonSQSAsync
How to write Rails
How to use rbenv
How to use letter_opener_web
How to use with_option
How to use java.util.logging
How to use map
Steps to deploy Struts 2.5.8
How to adapt Bootstrap
How to use Twitter4J
How to use active_hash! !!
How to install Docker
How to use MapStruct
How to use hidden_field_tag
How to use TreeSet
How to write dockerfile
How to uninstall Rails
How to install docker-machine
[How to use label]
How to make shaded-jar
How to write docker-compose
How to use identity
How to use hashes
How to write Mockito
How to create docker-compose
How to use JUnit 5
How to install MySQL
How to write migrationfile
How to build android-midi-lib
How to use Dozer.mapper
How to use Gradle
How to use org.immutables
How to use java.util.stream.Collector
How to use VisualVM
How to use Map
How to install ngrok
How to type backslash \
How to concatenate strings
How to deploy a container on AWS Lambda
How to delete BOM (UTF-8)
How to create an application
[Java] How to use Map
How to resolve Sprockets :: DoubleLinkError
[rails] How to post images
[AWS] How to check logs
How to resolve Git conflicts
How to use Chain API
How to lower java version
[Java] How to use Map
How to use Priority Queuing
Deploy Vapor Project to Heroku
How to uninstall Java 8 (Mac)
Java --How to make JTable
How to handle uploaded images
How to deploy to Heroku from a local docker image
How to deploy Java to AWS Lambda with Serverless Framework