This document outlines the setup process for running the services and configuring the necessary tools for the project.
The following services need to be started in the order listed to prevent errors when running your microservices:
- Redis
docker compose up -d redis
- MongoDB
docker compose up -d mongodb
- MySQL
docker compose up -d mysql
- PostgreSQL
docker compose up -d postgres
- RabbitMQ
docker compose up -d rabbitmq
- Elasticsearch
docker compose up -d elasticsearch
Note: Elasticsearch may take 5-10 minutes to fully initialize.
- Create a Kibana Service Token:
From the Elasticsearch container terminal, run:
bin/elasticsearch-service-tokens create elastic/kibana jobber-kibana
Copy the generated token and add it to the Kibana environment variable
ELASTICSEARCH_SERVICEACCOUNT_TOKEN
in yourdocker-compose
file.
- Update the
heartbeat.yml
file by replacing<your-ip-address>
with your system's IP address.
You can run the microservices using one of the following methods:
Run:
docker compose up -d
Run each service manually for better error monitoring:
npm run dev
Note: Always start the
gateway service
last, ensuring all other services are running beforehand.
To set up Jenkins for managing builds and deployments, follow these steps:
Create an RSA key pair:
ssh-keygen -t rsa -b 4096 -f jenkins_key
- Add the public key to
.env.jenkins
in yourdocker-compose
setup.
- Create a new node in Jenkins:
- Select Permanent Agent.
- Configure SSH using the generated private key.
Run the following commands on the Jenkins agent container:
apt update
apt install -y docker.io passwd curl
gpasswd -a jenkins docker
service docker start
docker restart <jenkins-agent-container-id>
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
chmod +x kubectl
mkdir -p ~/.local/bin
mv ./kubectl ~/.local/bin/kubectl
Install the following plugins:
- Docker
- NodeJS
- CloudBees Docker Build and Publish
- Kubernetes
- Kubernetes CLI
- Kubernetes Credentials Provider
- DockerHub Token:
- Add a new Username with password credential with ID:
dockerhub
.
- Add a new Username with password credential with ID:
- GitHub Token:
- Add a new Username with password credential with ID:
github
.
- Add a new Username with password credential with ID:
- Kubernetes Token:
- Add a new Secret text credential with ID:
jenkins-k8s-token
.
- Add a new Secret text credential with ID:
- NodeJS:
- Add a new NodeJS installation with global packages:
npm install -g npm@latest
.
- Add a new NodeJS installation with global packages:
- Docker:
- Add a Docker installation with automatic download from docker.com.
In Manage Jenkins, add a new cloud:
- Name:
minikube-k8s
- Type: Kubernetes.
- Press "Add Item"
- "jobber-reviews" as item name
- Select "Pipeline"
- Click on "OK"
- Description: "Jenkins pipeline for jobber review service."
- Select "Discard old builds"
- Max# of builds to keep: 5
- On Pipeline Definition: Dropbox -> Pipeline script from SCM, SCM -> Git, Paste the Repository URL (Repo from GitHub)
- Select Credentials: Your Credentials (GitHub)
- Press on "Save"
- Credentials: Jenkins kubernetes token
- Get the server kubectl ip:
kubectl config view
(On Your local machine terminal) - Copy the IP to the pipeline -> Paste on
Kuberenetes API endpoint
- Get the Cluster name -> Paster on
Cluster name
and onContext
- Press on
Generate Pipeline Script
and copy the script to Jenkinsfile
- Go to
jobber-reviews
Configuration - Mark
Github hook trigger for GITScm polling
- Go To ngrok site create a user and to the following
https://dashboard.ngrok.com/get-started/your-authtoken
- Run on Terminal
ngrok http 8080
- Copy the Forwarding ngrok url
- Go To GitHub Repo of
jobber-review
- Go to
Settings
- Press
Webhooks
- Press
Add Webhook
- Add Payload URL: Copy the Forwarding ngrok url + '/github-webhook/'
- Content Type Change to Application JSON
- Press
Add Webhook