This project was created to practice building Microservices with Spring-boot, Securing services with Keycloak and testing the performance of Spring JPA and hibernate query. In this project, there is a sample of the Rest-API project that contains a sample of Endpoint classes and a boilerplate class to make us easier to create CRUD Endpoint If you are interested, let's see a couple of documentation below.
This project is build by Spring-boot, you can see what is Spring-boot on their official website.
Goals of this project is "to learn and find a better way how to build a Microservices System Architecture using Spring-boot",
so the description on the README.md
file will be changed periodically following updates of this project.
There are some important things you should know about this project
- Root Folder description
ms-persistent-base
contains Base classes to creating Entity, Payload, or Responsems-security-base
is a spring-boot project that contains the Security Configuration will be used in all servicesspring-boot-ms-integration-test
is a spring-boot project that contains the Security Configuration will be used in all servicesdocker
contains files that needed to build Container of Keycloak and PostgresQLdocs
contains image assets and markdown (.md
) files of project documentationnginx
contains files that needed to run the Nginx
- Incomplete parts
- Performance test with JMeter is totally not created yet. This part will test some API endpoint from Rest Sample and Rest-Sample Reactive services to compare their performance
- Documentation of the Architecture
- This project is developed and tested on MacOS, it might not be working properly on Windows OS
To follow this guide, you need:
- Understand Java
- Understand Object Oriented Programming
- Understand Docker
- OpenJDK 21+ installed
- Apache Maven 3.9.6 or newer
- Docker
⚠️ It would be better you installsdkman
on your computer, and then usesdkman
to install OpenJDK
See this to installSDKMAN
Please follow these steps to run this project correctly
There is no special way to clone this project
We need to setup our localhost or our Local Machine to make a DNS running on our Local Machine
- Open your terminal
- Type
sudo vi /etc/hosts
and input your computer password - Press i on keyboard and type this on new line
it would be like
... 10.123.123.123 <domain name that you want> 10.123.123.123 keycloak.<domain name that you want>
or... 10.123.123.123 example.com 10.123.123.123 keycloak.example.com
or something else... 10.123.123.123 practicing-spring-boot.com 10.123.123.123 keycloak.practicing-spring-boot.com
- Press
Esc
on keyboard, then pressShift
+Z
twice
- Coming soon
- Please copy
docker_env.env.example
todocker_env.env
- Fill in these variable first
SERVER_HOST
is the domain name that you have added before to/etc/hosts
KEYCLOAK_HOST
is your domain name with prefixkeycoak.
- All environment variables with prefix
DATABASE_
KEYCLOAK_EXTERNAL_PORT
is accessible port of keycloak containerKEYCLOAK_ADMIN
andKEYCLOAK_ADMIN_PASSWORD
is a user credential will be used to sign in to keycloak admin consoleKEYCLOAK_KEYSTORE_PASSWORD
keystore password to secure the keycloak
This step is to make our domain works on our local
- Open your terminal
- Navigate to this project root folder
- Type
./create-local-dns.sh
and enter - The result would be like this
- To make sure your domain works, type this on terminal,
and
ping 10.123.123.123
if it works, the result would be like thisping <your domain>
PING q-learning.com (10.123.123.123): 56 data bytes 64 bytes from 10.123.123.123: icmp_seq=0 ttl=64 time=0.118 ms 64 bytes from 10.123.123.123: icmp_seq=1 ttl=64 time=0.299 ms 64 bytes from 10.123.123.123: icmp_seq=2 ttl=64 time=0.296 ms 64 bytes from 10.123.123.123: icmp_seq=3 ttl=64 time=0.220 ms
Certificate is needed to secure our keycloak
- Run
./create-certificate.sh
on your terminal - After that check on folder
./nginx/certs
,self-signed.crt
andself-signed.key
files would be there
- And then check on folder
./docker/keycloak/
,server.keystore
would be there
(don't worry about Dockerfile, it would be generated letter)
- On your terminal, please run this
./compose-up-keycloak-posgress.sh
- Please wait until finish, the result would be like this
Click the title to see the complete instruction