A boilerplate project for building scalable applications using NestJS with MariaDB, designed to run on AWS EKS.
- NestJS: A progressive Node.js framework for building efficient, reliable, and scalable server-side applications.
- MariaDB: An open-source relational database, providing a solid and reliable database solution.
- AWS EKS: Easily deploy and manage Kubernetes clusters using Amazon Elastic Kubernetes Service (EKS).
- Docker: Containerize the application for consistent and portable deployments.
- Kubernetes: Orchestrate your containerized applications using Kubernetes on AWS.
Make sure you have the following installed:
- Node.js (v14.x or later)
- Docker
- AWS CLI
- kubectl
- AWS IAM Authenticator for Kubernetes
- An existing EKS cluster and associated kubeconfig setup
-
Clone the repository:
git clone https://github.com/yourusername/nestjs-mariadb-eks-boilerplate.git cd nestjs-mariadb-eks-boilerplate
-
Install dependencies:
yarn install
-
Configure environment variables:
Create a .env file at the root of the project and configure the necessary environment variables:
DATABASE_HOST=your-mariadb-host DATABASE_PORT=3306 DATABASE_USER=your-username DATABASE_PASSWORD=your-password DATABASE_NAME=your-database
-
Build and run the Docker container:
docker-compose up --build
-
Build the Docker image:
docker build --platform linux/amd64 -t nestjs-mariadb-eks-boilerplate:latest .
-
Tag Docker Image for AWS ECR
docker tag nestjs-mariadb-eks-boilerplate:latest <your-aws-account-id>.dkr.ecr.<region>.amazonaws.com/<repository-name>:latest
-
Push the Docker image to a container registry (e.g., ECR, Docker Hub):
docker push <your-aws-account-id>.dkr.ecr.<region>.amazonaws.com/<repository-name>:latest
-
Modify k8s/app-deployment.yaml:
-
You MUST MODIFY the image URL in the
k8s/app-deployment.yaml
file to ensure Kubernetes pulls the correct image.image: <your-aws-account-id>.dkr.ecr.<region>.amazonaws.com/nestjs-mariadb-eks-boilerplate:latest
- Deploy to EKS using Kubernetes manifests:
-
Update the Kubernetes deployment YAML files in the k8s directory with your image name and other configurations.
-
Apply the manifests:
kubectl apply -f k8s/