Skip to content

Automated CI/CD pipeline for Node.js Express apps on AWS EC2 using CodeDeploy. Includes full environment setup, PM2 process manager, and production-ready configurations.

Notifications You must be signed in to change notification settings

shahnotes/aws-nodejs-ci-cd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS EC2 Setup for Node.js Application with CodeDeploy

This script automates the setup of a Node.js application on an Ubuntu EC2 instance using AWS CodeDeploy.

🔧 Step-by-Step Instructions

1. Update and Clean System Packages

sudo apt update
sudo apt upgrade
sudo apt autoremove
sudo apt autoclean

2. Install AWS CodeDeploy Agent

sudo apt install ruby-full
sudo apt install wget
wget https://aws-codedeploy-ap-south-1.s3.ap-south-1.amazonaws.com/latest/install
chmod +x ./install
sudo ./install auto
systemctl status codedeploy-agent
systemctl start codedeploy-agent
systemctl status codedeploy-agent

3. Install Node.js

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
node -v

4. Install PM2 Process Manager

npm install -g pm2

5. Create Symlinks (Optional but useful for scripting)

sudo ln -s "$(which node)" /sbin/node
sudo ln -s "$(which npm)" /sbin/npm
sudo ln -s "$(which pm2)" /sbin/pm2

6. Clone and Set Up the Application

sudo chown -R ubuntu:ubuntu /mnt
cd /mnt
git clone https://github.com/shahnotes/aws-nodejs-ci-cd
cd aws-nodejs-ci-cd
cp .env.prod .env
npm install --production

7. Run Node.js Application with PM2

sudo pm2 start app.js --name=nodejs-express-app
sudo pm2 save
sudo pm2 startup

You're all set! Your Node.js application is now running and managed by PM2, and the CodeDeploy agent is ready for deployment automation.

About

Automated CI/CD pipeline for Node.js Express apps on AWS EC2 using CodeDeploy. Includes full environment setup, PM2 process manager, and production-ready configurations.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published