A containerized Next.js application deployed using Docker, GitHub Actions, and Kubernetes (Minikube).
This project demonstrates a complete DevOps pipeline for a Next.js application:
- Containerization with multi-stage Docker build
- CI/CD using GitHub Actions and GitHub Container Registry
- Orchestration with Kubernetes manifests
- Local development with Minikube
nextjs-devops-assessment/ ├── .github/workflows/ │ └── docker-build-push.yml # GitHub Actions CI/CD workflow ├── k8s/ │ ├── deployment.yaml # Kubernetes Deployment │ └── service.yaml # Kubernetes Service ├── src/ # Next.js application source ├── Dockerfile # Multi-stage Dockerfile ├── next.config.ts # Next.js configuration └── package.json # Node.js dependencies
- Docker
- Kubernetes (Minikube)
- kubectl
- Node.js 18+
# Install dependencies
npm install
# Start development server
npm run devThe application will be available at http://localhost:3000
# Build the Docker image
docker build -t nextjs-app:latest .
# Run the container
docker run -d -p 3000:3000 --name nextjs-container nextjs-app:latestAccess the application at http://localhost:3000
The GitHub Actions workflow automatically:
- Builds Docker image on push to main branch
- Pushes image to GitHub Container Registry (GHCR)
- Uses proper image tagging with metadata
# Log in to GHCR
echo $GHCR_TOKEN | docker login ghcr.io -u USERNAME --password-stdin
# Build and tag image
docker build -t ghcr.io/username/nextjs-devops-assessment:latest .
# Push image
docker push ghcr.io/username/nextjs-devops-assessment:latest# Start Minikube cluster
minikube start
# Enable Minikube ingress (optional)
minikube addons enable ingress# Apply Kubernetes manifests
kubectl apply -f k8s/
# Check deployment status
kubectl get deployments
kubectl get pods
kubectl get services# Get the Minikube service URL
minikube service nextjs-service --url
# Or use port-forwarding
kubectl port-forward service/nextjs-service 8080:80Access the application via the provided URL or at http://localhost:8080
# View logs
kubectl logs -f deployment/nextjs-app
# Scale deployment
kubectl scale deployment nextjs-app --replicas=3
# Delete deployment
kubectl delete -f k8s/The application includes:
- Readiness Probe: Checks if container is ready to receive traffic
- Liveness Probe: Checks if container is running properly
Kubernetes deployment includes resource requests and limits:
- Requests: 100m CPU, 128Mi Memory
- Limits: 200m CPU, 256Mi Memory
- Multi-stage builds for smaller image size
- Non-root user for security
- Proper layer caching
- Minimal Alpine base image
- Health checks (readiness and liveness probes)
- Resource limits
- Multiple replicas for high availability
- Proper service exposure
- Non-root user in container
- Minimal base image
- Environment-specific configurations
- Minikube not starting: Ensure virtualization is enabled in BIOS
- Image pull errors: Check image tags and registry permissions
- Port conflicts: Change exposed ports in service.yaml
# Check cluster status
minikube status
# View all resources
kubectl get all
# Describe specific resource
kubectl describe deployment nextjs-app
# Check events
kubectl get events --sort-by=.metadata.creationTimestamp# Delete Kubernetes resources
kubectl delete -f k8s/
# Stop Minikube
minikube stop
# Delete Minikube cluster
minikube delete