Skip to content

Instantly share code, notes, and snippets.

@piotrekwitkowski
Last active July 20, 2023 18:44
Show Gist options
  • Save piotrekwitkowski/01eb5a687fc172c1cbdc61f290e675af to your computer and use it in GitHub Desktop.
Save piotrekwitkowski/01eb5a687fc172c1cbdc61f290e675af to your computer and use it in GitHub Desktop.
User Data script for EC2 to clone and run node app with pm2
#!/bin/bash
sudo yum update -y
sudo yum install -y git nodejs
git -v # Check git version
node -v # Check node version
npm -v # Check npm version
npm i -g pm2
export HOME=/home/ec2-user
pm2 -v # Check pm2 version
git clone https://github.com/owner/repo-name.git app
cd app
npm ci
npm run build
PORT=80 pm2 start npm --name app -- start
pm2 save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment