Deploy to Ruby on Rails Elastic beanstalk (Environment construction)

Overview

Deploy an application created with Ruby on Rails Use Elastic Beanstalk (EB) to build an environment in the shortest possible time. It is divided into IAM authority change, environment construction, and EB deployment. We will focus on deploying quickly, so please be aware of this if you need strict control.

table of contents

IAM authority change Environment construction EB Deployment

Environment construction

About the development environment

Ruby ・ ・ ・ 2.6.3 Rails ・ ・ ・ 5.0.7.2 Bundler ・ ・ ・ 2.1.4 or above OS ・ ・ ・ amazon Linux (cloud9) Rails was a little troublesome for SECRET_KEY ver management after 5.2, and 6.0 and above are still new (although I have not caught up with it), so there was no merit to raise the ver, so ver5.0.7. I'm using 2.

Since it is basically Linux, I think that the same operation can be performed on a Mac. However, in the free frame of cloud9, capacity is required due to rbenv, Ruby ver change, etc., and it has been expanded by about 10GB. It's OK to fold it as soon as you can deploy it, but is it actually around 500 even in a month? Click here for the extension method (https://docs.aws.amazon.com/ja_jp/cloud9/latest/user-guide/move-environment.html)

Environment

  1. rbenv install
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
  1. Put build as a plugin
mkdir -p ~/.rbenv/plugins
  1. Install (clone) ruby-build in ~ / .rbenv
cd ~/.rbenv/plugins
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
  1. Add to PATH → Add rbenv init to .bash_profile → Enable information added to path
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
exec $SHELL -l
  1. Check rbenv → Check the list that can be installed
rbenv -v
rbenv install --list
  1. Select the specified ver (2.6.5 this time)
rbenv install 2.6.5
  1. Set the installed version to global for the entire environment (please set it to local if there are other apps)
rbenv global 2.6.5
  1. Reload the set rbenv
rbenv rehash
  1. Specify the bundler ver and install
gem install bundler -v 2.1.4
  1. Rails new by specifying ver of rails
rails _5.0.7.2_ new myapp
  1. Addition of gem (It is safe to put what is necessary for development here and check the deployment in advance) pg, sqlite 1.3.6 or higher (pg can support heroku. sqlite specifies 1.3.6 or higher for cloud9. Dotenv-rails uses environment variables, so I will include it this time.)
gem 'sqlite3','~> 1.3.6'
gem 'pg'
gem 'dotenv-rails'

12.bundle install

myapp


bundle install --path vendor/bundle
  1. Added to gem file, pg, sqlite 1.3.6 or higher (pg can support heroku. sqlite is cloud9)

Gemfile


gem 'sqlite3','~> 1.3.6'
gem 'pg'
gem "dotenv-rails"
  1. Install while setting high-speed install with 4 cores (-j4 does not need to be entered in the future because it enters bundle config)

myapp


bundle install -j4
  1. Checking the operation of the app

myapp


rails g scaffold message subject body:text
rails db:create
rails db:migrate
rails s

Check the connection to the localserver of rails here. Thank you for your hard work.

Next, I will create a user with EB authority in IAM. It is not good to operate EB with Root authority, and it is not recommended to create an access key for Root.

IAM authority change

Recommended Posts

Deploy to Ruby on Rails Elastic beanstalk (Environment construction)
Deploy to Ruby on Rails Elastic beanstalk (EB deploy)
Deploy to Ruby on Rails Elastic beanstalk (IAM permission change)
Ruby on Rails 6.0 environment construction memo
From 0 to Ruby on Rails environment construction [macOS] (From Homebrew installation to Rails installation)
Deploy to Heroku [Ruby on Rails] Beginner
Muscle Ruby on Rails Day 1 ~ Environment Construction ~
Ruby on Rails --From environment construction to simple application development on WSL2
[Personal memo] Ruby on Rails environment construction (Windows)
Ruby on Rails development environment construction on M1 Mac
Rails engineer environment construction ruby2.7.1
Rails environment construction Rails5.2.1 ruby2.5.1 Catalina
Environment construction of Ruby on Rails from 0 [Cloud9] (From Ruby version change to Rails installation)
[Error] Switch environment construction to use Ruby on Rails oss (open source)
How to solve the local environment construction of Ruby on Rails (MAC)!
[Environment construction] Ruby on Rails 5.2 system development environment construction [within 1 hour]
[Environment construction Mac] Ruby on Rails (+ Webpacker handles errors)
Ruby on Rails environment construction using VirtualBox, Vagrant, cyberduck
[Ruby on Rails] From MySQL construction to database change
How to use Ruby on Rails
How to deploy Bootstrap on Rails
Rails on Docker environment construction procedure
Deploy Rails on Docker to heroku
[Procedure 1 for beginners] Ruby on Rails: Construction of development environment
[Environment construction] Get the Ruby on Rails 6 development environment within 1 hour
[Ruby on Rails] How to use CarrierWave
Ruby on Rails development environment construction with Docker + VSCode (Remote Container)
[Docker] Development environment construction Rails6 / Ruby2.7 / MySQL8
Preparing to introduce jQuery to Ruby on Rails
[Ruby on Rails] How to use redirect_to
[Ruby on Rails] How to use kaminari
[Ruby on Rails] Button to return to top
Steps to build a Ruby on Rails development environment with Vagrant
CentOS8.2 (x86_64) + ruby2.5 + Rails5.2 + MariaDB (10.3.17) environment construction
How to build a Ruby on Rails environment using Docker (for Docker beginners)
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
[Ruby on Rails] How to display error messages
How to link Rails6 Vue (from environment construction)
How to add / remove Ruby on Rails columns
[Ruby on Rails] Let's build an environment on mac
Deploy a Spring Boot application on Elastic Beanstalk
[Ruby on Rails] How to install Bootstrap in Rails
[Ruby on Rails] How to use session method
Rails Docker environment construction
Deploy RAILS on EC2
Ruby on Rails Elementary
Ruby on Rails basics
Ruby On Rails Association
[First environment construction] I tried to create a Rails 6 + MySQL 8.0 + Docker environment on Windows 10.
[Introduction] Try to create a Ruby on Rails application
Method summary to update multiple columns [Ruby on Rails]
[Ruby on Rails] How to write enum in Japanese
Build a Ruby on Rails development environment on AWS Cloud9
Docker the development environment of Ruby on Rails project
[Ruby on Rails] How to change the column name
[Updated from time to time] Ruby on Rails Convenient methods
[Ruby On Rails] How to reset DB in Heroku
(Ruby on Rails6) How to create models and tables
Rails6 development environment construction [Mac]
Ruby on rails learning record -2020.10.03