[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (5)

This is the way to build a production environment on AWS by turning a Ruby on Rails application created as a portfolio into a Docker container. The portfolio itself is here. [[Portfolio] Overview of the portfolio created during job change activities (Tec camp)] (https://qiita.com/sho_U/items/058e590325ee6833abb0)

I was suffering a lot, so I hope it helps someone.

title
1 Docker containerization of Rails application in local environment
2 Create a VPC on AWS. Create a public subnet
3 Create a private subnet
4 Create an EC2 instance
5 Create an RDS
6 Upload Docker container to AWS

Create an RDS.

I built an existing Ruby on Rails + MySQL application with Docker and created a database container in (1) to deploy it on AWS.

Actually, you can place an EC2 instance in a private subnet and a database container in it, but AWS has a service called RDS. Roughly speaking, RDS is an instance for a database that automatically configures it for increased availability and fault tolerance.

In addition, by arranging backup databases in different Availability Zones, even if a failure occurs in one database due to a disaster, etc., it can operate without problems. This is why I created two private subnets.

This time, we will create a database instance using this RDS.

Creating a subnet group

First, create a subnet group that combines two private subnets.

Enter the RDS dashboard, select your subnet group, and click Create DB Subnet Group.

image.png

Add the two private subnets you just created to the subnet.

You have now created a subnet group with different Availability Zones, such as:

IMG_5121AE56F9A4-1.jpeg

Parameter group settings

RDS does not directly touch the database settings, so set them in the parameter group.

image.png

The parameter group family matches the version of your development environment.

Option group settings

Enter the RDS dashboard, select an option group, and click Create Group.

image.png

Set the engine and major engine version according to the development environment.

Create an RDS.

Enter the RDS dashboard, select your database, and click Create Database. The following is a setting example. Please set according to your own operation.

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

Click "Create Database"

It's a little difficult to understand, but by connecting RDS with the subnet group and the security group for db as shown below, IMG_5255B692BA7F-1.jpeg

The result is the following configuration.

IMG_9352B52CF97B-1.jpeg

You have now created an RDS instance.

Continue to next time (6) Upload Docker container to AWS (https://qiita.com/sho_U/items/a1b5e4ddf13f3c42a722)

Recommended Posts

[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (5)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (6)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (3)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (2)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (1)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (4)
Build an environment with Docker on AWS
Deploy to heroku with Docker (Rails 6, MySQL)
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 ✕ Docker ✕ MySQL Introducing Docker and docker-compose to apps under development
Introducing Rspec with Ruby on Rails x Docker
[Ruby on Rails] Let's build an environment on mac
[Rails] How to build an environment with Docker
Building an environment for WordPress, MySQL and phpMyAdmin with Docker Compose on EC2
Rails deploy with Docker
Build a Ruby on Rails development environment on AWS Cloud9
Rails6 I tried to introduce Docker to an existing application
Build Rails (API) x MySQL x Nuxt.js environment with Docker
Build WordPress environment with Docker (Local) and AWS (Production)
How to install Docker in the local environment of an existing Rails application [Rails 6 / MySQL 8]
[Docker] Build a site on Hugo and publish it on GitHub
Rails application development environment construction with Docker [Docker, Rails, Puma, Nginx, MySQL]
Java: Start WAS with Docker and deploy your own application
How to deploy a Rails application on AWS (article summary)
Rails + MySQL environment construction with Docker
Deploy a Docker application with Greengrass
[Docker] How to back up and restore the DB data of Rails application on docker-compose [MySQL]
Ruby on Rails development environment construction with Docker + VSCode (Remote Container)
How to make an application with ruby on rails (assuming that the environment has been built)
Procedure for building a Rails application development environment with Docker [Rails, MySQL, Docker]
Build environment with vue.js + rails + docker
Build Rails environment with Docker Compose
How to build an environment with Docker, which is the minimum required to start a Rails application
(Ruby on Rails6) Creating a database and displaying it in a view
[Environment construction with Docker] Rails 6 & MySQL 8
How to build Rails + Vue + MySQL environment with Docker [2020/09 latest version]
Deploy Rails on Docker to heroku
Steps to build a Ruby on Rails development environment with Vagrant
Build a web application development environment that uses Java, MySQL, and Redis with Docker CE for Windows
Build debug environment on container --Build local development environment for Rails tutorial with Docker-
How to build a Ruby on Rails environment using Docker (for Docker beginners)
Enable Docker build cache on GitHub Action and deploy to Amazon ECS
Getting Started with Micronaut 2.x ~ Native Build and Deploy to AWS Lambda ~
Template: Build a Ruby / Rails development environment with a Docker container (Ubuntu version)
Template: Build a Ruby / Rails development environment with a Docker container (Mac version)
[Ruby on Rails] Creating an inquiry form
[Ruby on Rails] View test with RSpec
Building Rails 6 and PostgreSQL environment with Docker
Deploy heroku with Rails6 (Cloud9 + Ubuntu) + MySQL
Create Rails 6 + MySQL environment with Docker compose
[Docker] Development environment construction Rails6 / Ruby2.7 / MySQL8
Notes on using FCM with Ruby on Rails
[Ruby on Rails] Controller test with RSpec
Deploy to Heroku [Ruby on Rails] Beginner
Ruby on Rails application new creation command
[Ruby on Rails] Model test with RSpec
Deploy your application with VPC + EC2 + Docker.
Build an Ultra96v2 development environment on Docker 1
How to build Rails 6 environment with Docker
Introduce Docker to the development environment and test environment of existing Rails and MySQL applications