Module 13: Real-World Projects
🔹 Project 1: Deploying a React + Node.js + MongoDB Stack
📌 Goal
Run a full MERN stack (React frontend, Node.js backend, MongoDB database) using Docker containers.
🛠 Steps
1️⃣ React frontend Dockerfile
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
CMD ["npm", "start"]
EXPOSE 3000
2️⃣ Node.js backend Dockerfile
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["node", "server.js"]
EXPOSE 5000
3️⃣ MongoDB container
Use the official MongoDB image:
docker run -d --name mongo -p 27017:27017 mongo:6
4️⃣ Docker Compose file (docker-compose.yml)
version: "3.8"
services:
frontend:
build: ./frontend
ports:
- "3000:3000"
depends_on:
- backend
backend:
build: ./backend
ports:
- "5000:5000"
environment:
- MONGO_URL=mongodb://mongo:27017/mydb
depends_on:
- mongo
mongo:
image: mongo:6
ports:
- "27017:27017"
Run with:
docker-compose up -d
Now you have a React + Node.js + MongoDB stack running with one command. 🎉
🔹 Project 2: Setting up WordPress with SSL using Docker Compose
📌 Goal
Deploy a WordPress blog with MySQL backend and enable SSL (HTTPS) using nginx + certbot.
🛠 Steps
1️⃣ docker-compose.yml
version: "3.8"
services:
wordpress:
image: wordpress:latest
ports:
- "8080:80"
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wpuser
WORDPRESS_DB_PASSWORD: wppass
WORDPRESS_DB_NAME: wpdb
depends_on:
- db
db:
image: mysql:8
environment:
MYSQL_DATABASE: wpdb
MYSQL_USER: wpuser
MYSQL_PASSWORD: wppass
MYSQL_ROOT_PASSWORD: rootpass
volumes:
- db_data:/var/lib/mysql
nginx:
image: nginx:alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
- certs:/etc/letsencrypt
depends_on:
- wordpress
certbot:
image: certbot/certbot
volumes:
- certs:/etc/letsencrypt
entrypoint: >
certbot certonly --webroot
--webroot-path=/var/www/html
--email you@example.com
--agree-tos
--no-eff-email
-d yourdomain.com
volumes:
db_data:
certs:
2️⃣ Configure nginx.conf
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://wordpress:80;
}
}
3️⃣ Start the stack
docker-compose up -d
You’ll have WordPress running on https://yourdomain.com with free SSL from Let’s Encrypt. 🔐
🔹 Project 3: Building a CI/CD Pipeline for a Microservice
📌 Goal
Automate build, test, and deployment of a Node.js microservice using GitHub Actions and Docker Hub.
🛠 Steps
1️⃣ Sample Node.js app (server.js)
const express = require("express");
const app = express();
app.get("/", (req, res) => res.send("Hello from CI/CD pipeline!"));
app.listen(3000, () => console.log("App running on port 3000"));
2️⃣ Dockerfile
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["node", "server.js"]
EXPOSE 3000
3️⃣ GitHub Actions workflow (.github/workflows/cicd.yml)
name: CI/CD Pipeline
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
run: |
docker build -t yourdockerhub/myservice:${{ github.sha }} .
docker push yourdockerhub/myservice:${{ github.sha }}
4️⃣ Deploy to Server / Kubernetes
Pull the new image on your server:
docker run -d -p 3000:3000 yourdockerhub/myservice:<commit-sha>Or deploy with Kubernetes:
kubectl set image deployment/myservice myservice=yourdockerhub/myservice:<commit-sha>
🎯 Now your app builds, tests, and deploys automatically whenever you push code.
📌 Wrap-Up
Project 1 → MERN stack with Docker Compose.
Project 2 → WordPress with SSL using Docker + nginx + certbot.
Project 3 → CI/CD pipeline with GitHub Actions + Docker Hub.
These projects showcase how DevOps principles apply in real-world scenarios. They also prepare you for interviews, portfolio building, and handling real client/company tasks.
