EasyShop 🛍️ is a modern, full-stack e-commerce platform built with Next.js 14, TypeScript, and MongoDB. It features a beautiful UI with Tailwind CSS, secure authentication, real-time cart updates, and a seamless shopping experience.
- Architecture Overview
- Prerequisites
- Infrastructure Setup
- Jenkins Setup
- Continuous Deployment Setup (CD)
- NGINX Ingress + Cert-Manager
- HTTPS Configuration
EasyShop uses a GitOps approach with the following components:
- Infrastructure as Code (IaC): Terraform is used to provision and manage the cloud infrastructure.
- Containerization: Docker is used to containerize the application and its dependencies.
- Container Registry: Docker Hub is used as the container registry.
- CI Pipeline: Jenkins is used for continuous integration.
- CD Pipeline: ArgoCD is used for continuous delivery.
- Kubernetes: Kubernetes is used for container orchestration and management.
- Monitoring: Prometheus and Grafana are used for monitoring the application and infrastructure.
Important
Before you begin, ensure you have the following prerequisites:
- AWS Account: You need an AWS account/IAM role with appropriate permissions.
- Terraform: Install Terraform on your local machine.
- AWS CLI: Install the AWS Command Line Interface (CLI) on your local machine.
- Next.js 14
- TypeScript
- MongoDB
- Tailwind CSS for UI
- Secure Authentication
- Real-time Cart Updates
Follow the steps below to get your infrastructure up and running using Terraform:
# Add HashiCorp repo & install curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - sudo apt-add-repository "deb [arch=amd64] https://apt.releases. hashicorp.com $(lsb_release -cs) main" sudo apt-get update && sudo apt-get install terraform
Verify:
terraform -v
Initialize:
terraform init
Install & Configure AWS CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" sudo apt install unzip unzip awscliv2.zip sudo ./aws/install aws configure
Provide:
- AWS Access Key ID
- AWS Secret Access Key
- Default region name
- Output format
Note
Ensure your IAM role has programmatic access and required permissions.
git clone https://github.com/iemafzalhassan/easyshop--demo.git cd terraform
ssh-keygen -f terra-key chmod 400 terra-key
terraform init terraform plan terraform apply
Confirm with
yes
ssh -i terra-key ubuntu@<public-ip>
aws eks --region eu-west-1 update-kubeconfig --name tws-eks-cluster kubectl get nodes
cd /modules/bastion
./install-tools.sh
./system-service.sh
./deploy-applications.shsudo systemctl status jenkins
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
sudo systemctl enable jenkins sudo systemctl restart jenkins
Navigate to: Manage Jenkins → Plugins → Available Plugins
Install:
Docker PipelinePipeline View
Jenkins → Manage Jenkins → Credentials → Global → Add Credentials
- Kind: Username with password
- ID:
github-credentials
Same path as above
- Kind: Username with password
- ID:
docker-hub-credentials
Manage Jenkins → Configure System → Global Pipeline Libraries
- Name:
shared - Version:
main - Repo URL:
https://github.com/iemafzalhassan/EasyShop-jenkins-shared-lib
Ensure repo has:
vars/directory.
- Name:
EasyShop-jenkins-shared-lib
- GitHub hook trigger for GITScm polling
- Definition:
Pipeline script from SCM - SCM:
Git - Branch:
master - Script Path:
Jenkinsfile
ssh -i terra-key ubuntu@<bastion-ip>
aws configure
aws eks update-kubeconfig --region eu-west-1 --name tws-eks-cluster
./easyshop-deployment.shor:
kubectl create namespace argocd kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
watch kubectl get pods -n argocd
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "NodePort"}}' kubectl port-forward svc/argocd-server -n argocd 8080:443 --address=0.0.0.0 &
Get admin password:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
kubectl create namespace ingress-nginx
helm install nginx-ingress ingress-nginx/ingress-nginx --namespace ingress-nginx --set controller.service.type=LoadBalancerhelm repo add jetstack https://charts.jetstack.io helm repo update helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --version v1.12.0 --set installCRDs=true
---
## HTTPS Configuration
#### `04-configmap.yaml`
> ```yaml
> NEXT_PUBLIC_API_URL: "https://easyshop.letsdeployit.com/api"
> NEXTAUTH_URL: "https://easyshop.letsdeployit.com/"
> ```
#### `10-ingress.yaml`
> ```yaml
> annotations:
> cert-manager.io/cluster-issuer: "letsencrypt-prod"
> nginx.ingress.kubernetes.io/ssl-redirect: "true"
> ```
`Apply Changes:`
> ```bash
> kubectl apply -f 00-cluster-issuer.yaml
> kubectl apply -f 04-configmap.yaml
> kubectl apply -f 10-ingress.yaml
> ```
`Check Status:`
> ```bash
> kubectl get certificate -n easyshop
> kubectl describe certificate easyshop-tls -n easyshop
> ```
---
## **Congratulations! Deployment Complete!**
> Your full-stack e-commerce project is now deployed and live!