This document will help you to run application manually or via Docker Compose.
First, go to project's root and make the ./do
utility script executable if needed: chmod +x ./do
.
- Install recent JDK17.
- Install MariaDB (any reasonably recent version should work) then create
manon_dev
andmanon_dev_batch
schemas. - Package and run application via
./do rd
. Application will start on port 8080 withdev-mariadb
Spring profile.- You can also install PostgreSQL and use
dev-postgres
Spring profile. Package application via./do p
, go totarget/
directory and runjava -jar -Xms128m -Xmx512m -Dspring.profiles.active=dev-postgres manon.jar
- You can also install PostgreSQL and use
- application + Nginx + MariaDB + Redis + Greenmail + Prometheus
- log analysis via ELK + Cerebro
Application dockerized with Jib and OpenJDK11, two MariaDB databases (one for business tables, an other for Spring Batch tables), Nginx as HTTP proxy, Redis cache, Greenmail server to fake email messaging, an ELK stack to parse logs, and Prometheus to monitor metrics provided by Spring Boot Actuator. To proceed, follow these steps:
- Elasticsearch may need
sudo sysctl -w vm.max_map_count=262144
. - Install Docker: (otherwise, see online help from Docker website)
# install Docker Community Edition, tested on Lubuntu 18.04 LTS sudo apt-get remove docker docker-engine docker.io sudo apt-get install apt-transport-https ca-certificates curl software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" sudo apt-get update sudo apt-get install docker-ce sudo groupadd docker sudo usermod -aG docker $(whoami) sudo systemctl enable docker
- Install Docker Compose:
sudo rm /usr/local/bin/docker-compose sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose
- Build and install application image:
- via Jib:
./do jib
. - or via traditional
Dockerfile
:./do docker
.
- via Jib:
- Edit
docker-compose.yml
if needed (e.g. to customize ports). - Then run application image and dependencies via Docker Compose:
./do up
(it actually does:docker-compose -f ./docker/docker-compose.yml up -d
). - Application listens on port 8081 and its logs are stored in
~/manon-app-logs/
. - Check application healthcheck: wait 40s, then run
docker inspect --format "{{json .State.Health }}" manon | jq
.- Please note that healthcheck won't work if you built image with Jib:
openjdk
image doesn't containcurl
software, I installed it inDockerfile
only.
- Please note that healthcheck won't work if you built image with Jib:
- Check Swagger UI by visiting http://localhost:8000/swagger-ui.html, JSON OpenAPI docs http://localhost:8000/v3/api-docs and YAML OpenAPI docs http://localhost:8000/v3/api-docs.yaml.
- Check application connectivity by visiting
http://localhost:8081/actuator/health
. - Replace
8081
by8000
to access application via Nginx proxy. - Check Nginx error and access logs in
~/manon-nginx-logs
. - Launch a batch (e.g.
userSnapshotJob
)curl -X POST http://localhost:8000/api/v1/sys/batch/start/userSnapshotJob --header "Authorization: Bearer REPLACE_BY_ADMIN_TOKEN"
then check theuser_stats
anduser_snapshot
MariaDB tables. - Connect to MariaDB business database:
./do maria
(it connects to database via container's MySQL Client). You can now query tables. - Connect to MariaDB Spring Batch database:
./do maria-batch
(it connects to database via container's MySQL Client). You can now query tables. - Play with Prometheus by visiting
http://localhost:9090
(go to Alerts or Graph, then use auto-completion to fetch some data, e.g. "system_cpu_usage"). Checkhttp://localhost:9090/targets
to ensure bothprometheus
andspring-actuator
endpoints are UP. - Play with Grafana by visiting
http://localhost:3000
- log in with
admin
/admin
- go to
Configuration
,Data Sources
,Add data source
, choosePrometheus
, name:Prometheus
(case is important), url:http://prometheus:9090
,Save & Test
- go to
Dashboards
,Manage
,Import
, past content of manon-dashboard.json file,Load
,Import
- go to
Dashboards
,Home
, open themanon
dashboard: you should see JDBC and CPU metrics
- log in with
- Run ELK stack images via Docker Compose:
./do upelk
. - Visit
http://localhost:5601
and go toDev Tools
. You can now send queries to Elasticsearch to find some logs:- Get application logs via:
GET /manon-app-*/_search
. - Get Nginx access logs via:
GET /manon-nginx-access-*/_search
. - You can delete these logs via:
DELETE /manon*
. Play with application and show logs again.
- Get application logs via:
- Optional: run Cerebro via Docker Compose:
./do upcerebro
.- Visit
http://localhost:9000
and selectMain Cluster
(it's an alias forhttp://elasticsearch:9200
, seedocker/cerebro/cerebro.conf
file for details).
- Visit
You can now stop images via ./do stopcerebro
(Cerebro), ./do stopelk
(ELK stack), ./do stop
(application and dependencies).