[Ruby] AWS☆☆☆ Road to deployment 3 (short version, all 4 times)

1 minute read

1) Background

It is the third time. In order to deploy our own portfolio, we finally start rails via unicorn. Since there are so many AWS related procedure articles, I will describe the procedure very briefly here, including the memorandum. We will proceed with all four episodes.

2) Environment

Item Content
OS.Amazon Linux AMI release 2018.03
Ruby v2.5.1
Ruby On Rails v5.2.4.3
MySQL v5.6
Unicorn v5.4.1

3) Content

** I think about 75 minutes with the following settings. (30 minutes if you know the setup) **
  • All operations are on AWS, except for [Local Machine].

(1) [Local machine] Unicorn settings (20 minutes)

-Write unicorn in Gemfile of target application -Run bundle install locally (Unicorn introduced) -Editing the configuration file (unicorn.rb) created by Unicorn installation

(2) Git cloning (15 minutes)

  • Arrangement of app storage folder and granting permissions
  • Cloning application from Git (*)
  • Create AWS-swap area to run the application (see separate article)

*The following is required for cloning. (1) The local unicorn settings from earlier are pushed (2) Latest git and master (3) DB user settings for the production environment (production)

(3) Production deployment setting (30 minutes)

  • Install bundler for application
  • Run bundle install of the app (it will take some time)
  • Get app secret key (rake secret)
  • Set db user password (match with production) and private key in environment variables
  • Create app db (execute DB-Create and DB-Migrate)
  • precompile the assets directory

(4) Production Rails startup (10 minutes)

  • Open instance port 3000 to start rails app
  • service invocation via unicorn

Once you have done this, access “http://ElasticIP:3000” and you should be taken to the top page of your application.

The above is a short description. Up to this point, I didn’t go straight, and an error was output. This area varies depending on the environment and settings, so I would like to post error countermeasures in another article.