• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Deploy My First Node.js App on AWS: EC2 + Docker + RDS MySQL Explained

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Hi everyone,
My name is Soumen Bhunia. This is my first blog. In this blog, I build and deploy my first Node.js app using Docker, hosted on an AWS EC2 instance, and connected to a MySQL database hosted via Amazon RDS

Technologies Used

Step-by-Step Setup Guide

Step 1: Create an RDS MySQL Instance

  1. Go to

    Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

    .
  2. Click Create Database.
  3. Choose:
    • Engine type: MySQL
    • Use case: Free Tier
  4. Under Settings:
    • Set a DB instance identifier
    • Master username: admin
    • Master password: Set a secure password (avoid special characters like @, %, etc.)
  5. In Connectivity:
    • Enable Public access = Yes (for development purposes)
    • Create a new VPC security group
    • Add an inbound rule to allow MySQL/Aurora (port 3306) from Anywhere (0.0.0.0/0)

After RDS is created, copy the endpoint/hostname — you'll use it to connect your app to the database.

Step 2: Launch and Configure an EC2 Instance


  1. Go to

    Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

    .


  2. Launch a new instance:
    • Amazon Linux 2 AMI (Free Tier eligible)
    • Choose t2.micro (Free Tier)

  3. In Security Group, allow:
    • HTTP (port 80) – for web traffic
    • SSH (port 22) – for connecting to the instance
    • Optional: Restrict access by IP for SSH
Step 3: Install Docker on EC2


Once connected to EC2, run the following:


sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -aG docker ec2-user

Important: Log out and log back in to activate Docker permissions for ec2-user.

Step 4: Run the Dockerized Node.js App


Pull the Docker image:


sudo docker pull philippaul/node-mysql-app:02

Then run your container, replacing the values with your actual RDS credentials:


docker run --rm -p 80:3000 \
-e DB_HOST="your-db-endpoint.rds.amazonaws.com" \
-e DB_USER="admin" \
-e DB_PASSWORD="your-db-password" \
-d philippaul/node-mysql-app:02

Your app should now be accessible at your EC2 public IP on port 80.

Web interface screenshot



Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Optional: Test the MySQL Connection


You can test connecting to the database from inside EC2 using a MySQL Docker client:


docker run -it --rm mysql:8.0 mysql \
-h your-db-endpoint.rds.amazonaws.com \
-u admin -p

Enter your password when prompted. If you connect successfully — your EC2 can talk to your RDS instance.

Wrapping Up


Thank you for investing your time in reading this article! I hope these insights have provided you with practical value and a clearer understanding of the topic. Your engagement and learning journey matter to me.

What's Next?


Stay tuned for more in-depth articles where we'll explore other exciting cloud projects and DevOps topics.

Let's Connect!


I'd love to hear your thoughts and experiences! Drop your comments below or connect with me on

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

. Your feedback helps me create more valuable content for our tech community.

Happy Learning!


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу