This repository contains a Next.js microfrontends project template, leveraging NX for build optimization, deployed on Azure AKS with Nginx for ingress routing.
-
NX for Microservices: Nx is a build system with built-in tooling and advanced CI capabilities
-
Azure Kubernetes Service (AKS): Deploy your microservices with AKS. AKS offers container orchestration, automatic scaling, and simplified management of your microservices.
-
Nginx Ingress: Easily deploy Nginx Ingress using the provided scripts. Nginx Ingress acts as a reverse proxy and load balancer
-
Next.js Microfrontends: Develop and deploy multiple Next.js microfrontends as part of your microservices architecture
├── apps/
│ ├── app/ # Directory for the "app" microservice.
│ └── marketing/ # Directory for the "marketing" microservice.
├── azure.pipelines.yml # Configuration file for Azure Pipelines, enabling CI/CD workflows.
├── conf/nginx.conf # Configuration file for Nginx, specifying the server settings and routing rules.
├── docker-compose.yml # Docker Compose file for local development, defining the services and their dependencies.
├── ingress.yaml # YAML file defining the Kubernetes Ingress resource for routing external traffic to the microservices.
├── kubernetes.yaml # YAML file containing the Kubernetes resource configurations for deploying the microservices.
├── nx.json # Configuration file for the NX workspace, specifying the project commands and dependencies.
└── packages/ # Directory containing any additional packages or shared code used in the project.
To deploy the project locally, follow these steps:
- Start nginx to route requests properly:
docker compose up
- Install the dependencies:
npm install
- Start all services, including the two front-end microservices on
localhost:3000
(app) andlocalhost:3001
(marketing):npm run dev
- Visit
localhost:3000
to access theapp
service, andlocalhost:3001
to access themarketing
service.
To deploy the project on Azure AKS, follow these steps:
- Create the AKS cluster using Azure CLI or the portal. Refer to the official documentation for detailed instructions.
- Register Azure Container Registry with the container. Follow the steps provided in the official documentation.
- Build and push the Docker images for the
app
andmarketing
Next.js images to Azure Container Registry (ACR). - Apply the image and resource configuration using the following command:
kubectl apply -f ingress.yaml kubernetes.yml
- Retrieve the external IP address of the ingress service by running:
kubectl get service
. Visit the provided IP address to access the webpage.
That's it! You've deployed the project locally or on Azure AKS with Nginx Ingress.