Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #84 from igrowker/devops
Browse files Browse the repository at this point in the history
Devops
  • Loading branch information
sarap13 authored Dec 4, 2024
2 parents 2364412 + da724f8 commit 1d60e46
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
26 changes: 17 additions & 9 deletions .github/workflows/CI-CD-Pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Build and Push Docker Images
uses: docker/build-push-action@v6
with:
context: ../../Dockerfile
context: ./
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/pawsome-node:backend
Expand Down Expand Up @@ -83,15 +83,23 @@ jobs:
- name: Set up SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.AWS_SSH_KEY }}" > ~/.ssh/aws-key.pem
chmod 400 ~/.ssh/aws-key.pem
echo "${{ secrets.AWS_SSH_KEY }}" > ~/.ssh/backend_key.pem
chmod 400 ~/.ssh/backend_key.pem
- name: Deploy Backend to AWS EC2
run: |
ssh -o StrictHostKeyChecking=no -i ~/.ssh/aws-key.pem ec2-user@your-ec2-public-ip "
cd ../../i004-pawsome-back || git clone https://github.com/igrowker/i004-pawsome-back ../.. && cd /i004-pawsome-back;
git pull;
npm install;
npm run build;
pm2 reload ecosystem.config.js || pm2 start ecosystem.config.js --env production
ssh -o StrictHostKeyChecking=no -i ~/.ssh/backend_key.pem [email protected] "
cd /home/ec2-user || mkdir /home/ec2-user;
if [ ! -d /home/ec2-user/i004-pawsome-back ]; then
git clone https://github.com/igrowker/i004-pawsome-back /home/ec2-user/i004-pawsome-back;
fi;
cd /home/ec2-user/i004-pawsome-back;
git pull;
npm install;
npm run build;
pm2 reload ecosystem.config.js || pm2 start ecosystem.config.js --env production;
"
8 changes: 4 additions & 4 deletions ecosystem.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ module.exports = {
apps: [
{
name: "i004-pawsome-back",
script: "/dist/index.js",
watch: true,
instances: 1,
exec_mode: "fork",
script: "./dist/index.js",
watch: process.env.NODE_ENV === "development",
instances: "max",
exec_mode: "cluster",
env: {
NODE_ENV: "development",
},
Expand Down

0 comments on commit 1d60e46

Please sign in to comment.