Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 259

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 62k
Author
Asked: November 25, 20242024-11-25T09:14:07+00:00 2024-11-25T09:14:07+00:00

Deploy Server App to EC2

  • 62k

This is the part where we deploy our Server App to EC2. Here is how we do it:

Add New Rules in Security Group

We need to add new inbound rules to expose our app in Docker. For the server app, we set the port to be 3000, so we need to add it here. You can add the rules inside security groups. Inside security groups page, click on Edit inbound rules.

Image description

Next, add Custom TCP with the 3000 as the port range and set the source to 0.0.0.0/0, then click Save rules button to finish.

Image description

Connect to EC2 Instance

This can be done by connecting to the instance in the AWS EC2 console or by using SSH.

Connect to EC2 Instance in AWS Console

In your EC2 dashboard, select the instance that you want to connect to, then click the Connect button.

Image description

After that, click the Connect button again.

Image description

The console instance terminal will then be shown.

Image description

Connect to EC2 Instance by SSH

To connect to the instance by SSH, we need the .pem file we downloaded when we created the instance. The first step is to set the .pem file permissions to read-only for the owner and no permissions for others. To do this, we can run this command:

chmod 400 file_name.pem 
Enter fullscreen mode Exit fullscreen mode

If you are on Windows, you can run this command instead.

icacls my-key-pair.pem /inheritance:r /grant:r "$($env:USERNAME):(R)" 
Enter fullscreen mode Exit fullscreen mode

Then we need to get the public IP of the instance.

Image description

Finally, run this command to connect to the instance:

ssh -i my-key-pair.pem ubuntu@3.27.113.187 
Enter fullscreen mode Exit fullscreen mode

Image description

Install Docker

The Docker installation guide on Ubuntu can be found here. After installation finishes, we need to run this command to make the docker compose command work.

sudo chmod 666 /var/run/docker.sock 
Enter fullscreen mode Exit fullscreen mode

Create Github SSH

For this part, we will use SSH to clone our repository from GitHub. First, enter the .ssh folder:

cd ~/.ssh/  
Enter fullscreen mode Exit fullscreen mode

Then generate the .pub file. You can name the file whatever you want; for this file, I named it my_ssh

ssh-keygen -t rsa 
Enter fullscreen mode Exit fullscreen mode

Image description

Copy the text inside .pub

cat ./my_ssh.pub 
Enter fullscreen mode Exit fullscreen mode

and add it to your GitHub SSH keys.

Image description

To test the key, run this command:

eval $(ssh-agent) ssh-add ./my_ssh 
Enter fullscreen mode Exit fullscreen mode

Image description

And test the connection:

ssh -T git@github.com 
Enter fullscreen mode Exit fullscreen mode

Image description

If we've done this part correctly, we should see that the SSH is being used.

Image description

Clone Repository

To copy the repository, run this command:

git clone git@github.com:akbarnafisa/aws-devops-fullstack.git 
Enter fullscreen mode Exit fullscreen mode

Then switch to the branch that you want to deploy:

git checkout remotes/origin/6-setup-docker-production-mode 
Enter fullscreen mode Exit fullscreen mode

Finally, run our Docker Compose file using this command:

docker compose -f docker-compose.prod.yml 
Enter fullscreen mode Exit fullscreen mode

If everything is successful, we will be able to access our app at this URL.

http://<public_ip>:3000/api/todo 
Enter fullscreen mode Exit fullscreen mode

Image description

awsdevopsjavascriptwebdev
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 1k
  • Popular
  • Answers
  • Author

    How to ensure that all the routes on my Symfony ...

    • 0 Answers
  • Author

    Insights into Forms in Flask

    • 0 Answers
  • Author

    Kick Start Your Next Project With Holo Theme

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.