Skip to content

arbrsts/nx-azure-microservice-with-nginx-ingress

Repository files navigation

nx-azure-microservice-with-nginx-ingress by arbrsts

This repository contains a Next.js microfrontends project template, leveraging NX for build optimization, deployed on Azure AKS with Nginx for ingress routing.

Key Features

  • 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

Project structure

├── 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.

Deployment

Local

To deploy the project locally, follow these steps:

  1. Start nginx to route requests properly: docker compose up
  2. Install the dependencies: npm install
  3. Start all services, including the two front-end microservices on localhost:3000 (app) and localhost:3001 (marketing): npm run dev
  4. Visit localhost:3000 to access the app service, and localhost:3001 to access the marketing service.

Azure

To deploy the project on Azure AKS, follow these steps:

  1. Create the AKS cluster using Azure CLI or the portal. Refer to the official documentation for detailed instructions.
  2. Register Azure Container Registry with the container. Follow the steps provided in the official documentation.
  3. Build and push the Docker images for the app and marketing Next.js images to Azure Container Registry (ACR).
  4. Apply the image and resource configuration using the following command: kubectl apply -f ingress.yaml kubernetes.yml
  5. 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.

About

NextJS microfrontends template with Azure AKS and Nginx ingress

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published