Booksriver Backend Server is a Java SpringBoot application designed to support the Booksriver Android app. It supports both Docker Compose and Kubernetes for container orchestration.
The backend is built using a microservices architecture with Eureka for service discovery and a Gateway for routing requests.
- Java SpringBoot
- Eureka for service discovery
- Gateway for routing requests
- RabbitMQ for message queue
- Docker Compose and Kubernetes for container orchestration
- PostgreSQL as relational database
mvn clean install -DskipTests=true
docker-compose build && docker-compose up
It my take some time (~30 secs or more) to correctly register microservices on Eureka
Try it at http://localhost/user-server/auth/login
sudo -su postgres psql -U postgres
create database booksriver_user;
create database booksriver_book;
create user booksriver with password 'booksriver';
grant all privileges on database booksriver_user to booksriver;
grant all privileges on database booksriver_book to booksriver;
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.9-management
From the RabbitMQ container terminal run
rabbitmqctl add_user admin admin
rabbitmqctl set_user_tags admin administrator
Try it at http://localhost:15672/
Credentials are admin admin
Run modules in the following order (important!):
- Eureka Server
- Gateway Server
- User Server
- Book Server
It my take some time (but should be instant) to correctly register microservices on Eureka
Try it at http://localhost/user-server/auth/login
http://localhost:9001/swagger-ui/index.html?configUrl=/rest-api-docs/swagger-config
http://localhost:9002/swagger-ui/index.html?configUrl=/rest-api-docs/swagger-config
Start Minikube
minikube start
minikube dashboard
It should open the dashboard in a browser. Then in another terminal, build your images:
eval $(minikube docker-env)
mvn clean install -DskipTests=true
docker-compose build
Then apply Kubernetes files
kubectl apply -f kubernetes/
In the dashboard, if everything looks green, u good to go! (It may take a while for user-server and book-server to correctly connect to their database service)
To access swagger, just type these two commands in two separated terminals
kubectl port-forward svc/user-server 9001:9001
kubectl port-forward svc/book-server 9002:9002
To run on kubernetes using images from docker hub, you need to edit:
- user-server-depoloyment.yaml
- book-server-depoloyment.yaml
- eureka-server-depoloyment.yaml
- gateway-server-depoloyment.yaml
and replace imagePullPolicy: Never
to imagePullPolicy: ""
and image:<local-image>
to image:<remote-image>
Then procede with the same steps from above, without the commands from build your images
We welcome contributions from other developers. If you'd like to contribute to the Booksriver Backend Server, follow these steps:
- Fork the repository on GitHub
- Clone your fork to your local machine
- Make your changes and test them thoroughly
- Submit a pull request with your changes