Application template based in Ontimize Boot (java 11).
Use this template to generate an application with a standard structure and a predefined Ontimize configuration for Ontimize authentication and a unique database, using PostgreSQL.
Take a look at application.yml and Ontimize Boot documentation to customize as needed.
Several Spring Boot configuration files are provided. It is recommended to use environment variables in Spring configuration files for configuration values that depend on the environment.
For K8s environment it is recommended that Spring actuator is configured in a different port than the application. (see application-staging.yml)
This application is ready to be deployed in a Kubernetes Cluster, using provided Helm charts (in ./charts folder).
Other files provided:
./Dockerfile: Provided as is. Adapt as needed.
./.git/workflows/maven-build-docker-ecr.yaml: Adapt as needed. Provided setup is:
- Fires on push in develop branch
- Performs maven verify
- Builds docker image
- Extracts project version from pom.xml
- Updates version in ./charts/xxx/Chart.yaml
- Pushes docker image to Amazon AWS ECR (login, repository, etc. are automatically done. Credentials are not needed if repository organization is imatia-innovation).
Note: Amazon AWS ECR can be customized depending on infrastructure needs and setup. Provided configuration is standard and should work in most cases.
This application is ready to be deployed on a local machine, using provided docker compose files (in ./ folder):
./docker-compose.yaml: Adapt as needed. Provided setup is:
- Builds docker image
- Runs database (Defined in docker-compose-services.yaml)
- Runs application
./docker-compose-services.yaml: Adapt as needed. Provided setup is:
- Runs database
The services required to run the application, such as the database, are provided in a separate file to allow to run the services only and to be able to launch the application from an IDE.
-
Go to the application folder
cd cd2023bbe1g2
-
With docker privileges run the following command to start the deployment:
docker compose up
The application is deployed as a docker container in the url: http://localhost:8080
-
List the pods:
docker ps
-
Show the logs of each container:
docker logs -f id_container
-
Access the console of the container:
docker exec -it id_container sh
-
Stop the deployment:
docker compose down docker volume prune
The parameters in the application-local.yaml file must match the values of the development services, such as the database. By default, the parameters match the values in the docker files.
-
Go to the application folder
cd cd2023bbe1g2
-
If a deployment of a development services are not available, run the provided docker compose file to start the services:
docker compose -f docker-compose-services.yaml up
-
Compile and deploy the application with the following commands:
mvn clean install -Plocal java -jar cd2023bbe1g2-boot/target/cd2023bbe1g2-boot.jar --spring.profiles.active=local
-
The application is accessible using the url: http://localhost:8080
By default the application provides two users. Adapt as needed:
-
Admin:
- Role:
Administrator
- Username:
admin
- Password:
adminuser
- Role:
-
Demo:
- Role:
User
- Username:
demo
- Password:
demouser
- Role:
-
Go to the application folder and run an install:
mvn clean install -Plocal
-
Go to the
cd2023bbe1g2-boot
folder and run the commandmvn spring-boot:run -Dspring-boot.run.profiles=local
or go to the
cd2023bbe1g2-boot/target
folder and run the commandjava -jar cd2023bbe1g2-boot/target/cd2023bbe1g2-boot.jar --spring.profiles.active=local
Use the following URL to access the application: http://localhost:8080
The application adopts the API-first approach using the OpenAPI specification.
The REST API is defined using yaml files and, in compile time, the Ontimize OpenAPI plugin generates the models and the controller interfaces that must be implemented on the application.
The Ontimize OpenAPI plugin also provides the Swagger user interface and it will be available at http://localhost:8080/swagger-ui/index.html.