
Deploy Node.js & Express Application Using CI/CD (GitHub Actions + Docker)
Quick Flow before deep dive Developer pushes code to GitHub GitHub Actions triggers pipeline Pipeline connects to EC2 via SSH Pulls latest code Rebuilds Docker image Runs container using Docker Compose Application is live on EC2 public IP Prerequisites Node.js (v16+) and npm installed on local machine Git installed on local machine and basic commands knowledge Docker installed on local machine GitHub account AWS account Basic cloud/devops knowledge 1. Create a Simple Node.js + Express Application Initialize a Node.js project: npm init Install required dependencies: npm install express npm install @types/express --save-dev 2. Update package.json Add the following: { "name" : "node-app" , "version" : "1.0.0" , "type" : "module" , "scripts" : { "start" : "node index.js" } } 3. Create index.js import express from ' express ' ; const app = express (); const PORT = process . env . PORT || 8080 ; app . get ( ' / ' , ( req , res ) => { res . send ( ' Hello from the server! ' ); }); app . liste
Continue reading on Dev.to
Opens in a new tab



