Creating a Dockerfile that builds and runs the [Link] app.
FROM node:20-alpine
WORKDIR /var/www/html
COPY package*.json ./
COPY . .
EXPOSE 3000
CMD ["node", "[Link]"]
This Dockerfile uses node:20-alpine to run a [Link] app. It sets the work folder, copies
package*.json and app files, exposes port 3000, and runs node [Link].
Adding a [Link] file for local development.
version: '3.8'
services:
node-app:
build: .
container_name: node_app
ports:
- "3000:3000"
restart: always
command: sh -c "npm install && node [Link]"
Auto-builds and runs the [Link] app on port 3000 with dependencies installed.
The app is running on port 3 and displaying a log message when accessed.
CI/CD with GitHub Actions
Step 1: Create or choose a repository, and pick a project
Step 2: Make a CI/CD yaml file under Github/Workflows and open GitHub Actions
in repository to start building your CI/CD workflow
Triggering the CI/CD
Step 3: Make changes to your code to trigger your CI/CD pipeline
Step 4: workflow visualizer and live logs to get a full look into how pipeline is
running
Working Process
● Github checks out code
● Builds Docker image
● Starts app in background
● Wait 10s
● Test with Curl
● Print Success
Optional
1. Create Docker Hub Account
● Go to: [Link]
● Sign up (free)
● Username: punksoul2580
● Create a public repository: devops-test-app
Tagging the images
Docker login in cli
Push the images
Verify on Docker Hub
Go to:[Link]
Logging and Monitoring
[Link] runs a basic Express server but does not expose any application-level metrics. Node
Exporter only collects system-level metrics and cannot track your app’s requests. Without a
Prometheus-compatible /metrics endpoint or tracked counters, there is nothing for Prometheus to
scrape, so no metrics are shown.
Reasons:
1. No Prometheus client installed in the [Link] app (prom-client is missing).
2. No /metrics endpoint exists to expose application metrics.
3. Node Exporter only collects host-level metrics, not application-level metrics.
4. Prometheus has nothing to scrape from the app because the app doesn’t expose metrics in
a Prometheus-compatible format.
How to check logs
● Open [Link]
● Login: admin / admin
● Go to Explore → Select Loki or grafana or dashboard
● Run query: {container_name="node_app"}
● You’ll see: Request received on /
Bash Automation Script
#!/bin/bash
APP_NAME="node_app"
# Check if Docker is installed
if ! command -v docker &> /dev/null
then
echo "Docker is not installed. Please install Docker first."
exit 1
fi
# Build Docker image
echo "Building Docker image..."
docker compose build
# Start the app
echo "Starting the app using docker compose..."
docker compose up -d
# Wait a few seconds
sleep 5
# Check if container is running
if [ "$(docker ps -q -f name=$APP_NAME)" ]; then
echo "Success: $APP_NAME container is running."
else
echo "Error: $APP_NAME container failed to start."
docker compose ps
exit 1
fi
The [Link] script automates setting up a [Link] app in Docker. It first checks if Docker is
installed; if not, it exits with an error. Then it builds the Docker image using docker compose
build, starts the containers in the background with docker compose up -d, waits 5 seconds, and
checks if the node_app container is running. If yes, it prints a success message; otherwise, it
shows an error and the container status before exiting.
Output of [Link]