Last active
July 20, 2023 18:44
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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