Automated the build and deployment of a Node.js application using GitHub Actions and Docker.
The pipeline builds the app, creates a Docker image, pushes it to DockerHub, and allows deployment locally.
-
Copied App Files
- Used a simple Node.js app (
app.js,package.json,compile.json).
- Used a simple Node.js app (
-
Created Dockerfile
- Added
Dockerfileand.dockerignorefor containerization.
- Added
-
Created GitHub Repository
- Pushed the project files to a new GitHub repo.
-
Added GitHub Secrets
DOCKER_USERNAME→ DockerHub usernameDOCKER_PASSWORD→ DockerHub password/token
-
Created Workflow File
- Added
.github/workflows/main.ymlwith steps for:- Checkout
- Install dependencies
- Test
- Build Docker image
- Push image to DockerHub
- Added
-
Pushed Code to GitHub
- Triggered the GitHub Actions workflow.
- Workflow successfully built and pushed the image to DockerHub.
-
Deployment
- Pulled the image from DockerHub locally.
- Ran the container with:
docker run -p 3000:3000 l4kshya/nodejs-demo-app:latest
- Verified app at
http://localhost:3000.
- Automated CI/CD pipeline completed.
- Docker image successfully available on DockerHub.
- Application tested and deployed locally from the pushed image.