A minimal Node.js Express application that displays the current date and time. Built for containerized deployment with automated CI/CD using Docker and GitHub Actions.
- 📅 Real-time date & time display
- 🖼️ Static frontend via
public/index.html - 🐳 Fully containerized using Docker
- 🔄 Automated CI/CD with GitHub Actions:
- Build & push Docker image
- Scan using Trivy for vulnerabilities
- Test deployment via
curl
This project uses GitHub Actions to automate the container lifecycle:
Triggered on every push to the main branch:
- Checks out the code
- Logs into Docker Hub securely via GitHub Secrets
- Builds Docker image:
demo-nodeapp-v1:latest - Tags & pushes image to Docker Hub
on:
push:
branches:
- mainRuns after successful build:
- Pulls the latest Docker image
- Scans using Trivy for
CRITICALandHIGHvulnerabilities - Outputs results in SARIF format
needs: buildRuns after scan job completes:
- Pulls image from Docker Hub
- Runs container in detached mode
- Waits for app readiness
- Verifies HTTP response via
curl
needs: scanInsert your workflow screenshots here for visual reference
Pre-requisite: Node.js installed
# Clone and run
git clone https://github.com/<your-username>/<repo-name>.git
cd <repo-name>
npm install
node app.js🔗 Access app at: http://localhost:3000
# Build Docker image
docker build -t demo-nodeapp-v1 .
# Run container
docker run -p 3000:3000 demo-nodeapp-v1Configure the following secrets in your repo:
| Secret Name | Purpose |
|---|---|
DOCKERUSERNAME |
Docker Hub username |
DOCKERPASSWORD |
Docker Hub password or token |
📍 Go to: Settings → Secrets and variables → Actions
| File | Description |
|---|---|
docker.yml |
Builds & pushes Docker image to Docker Hub |
scan.yml |
Performs Trivy scan for vulnerabilities |
test.yml |
Runs container & validates app with curl |
docker pull <your-image>:latest
trivy image <your-image>:latest- Pulls image from Docker Hub
- Runs container in background
- Waits for a few seconds
- Verifies with
curlon port 3000
├── app.js
├── package.json
├── public/
│ └── index.html
├── Dockerfile
└── .github/
└── workflows/
├── docker.yml
├── scan.yml
└── test.yml
Once the CI/CD pipeline runs:
- ✅ Image is built and pushed
- 🔍 Trivy scan confirms vulnerability status
- 🚀 App is deployed and tested successfully
$ curl http://localhost:3000
Current Date & Time: 2025-08-04 20:08:00Each workflow job produces useful logs for debugging and validation:
| Job | Logs & Output |
|---|---|
| Build & Push | Docker layer logs, image tag confirmations |
| Trivy Scan | Security summary, SARIF logs, exit codes |
| Test Job | Container boot, curl response check |




