Container Module¶
- Main Application
- Create Beans(e.g.: Domain Service)
- Configurations
- Properties.
This module has control over the service and injects different packages before building the app, Good Look! It is straightforward and has a single responsibility (S of SOLID) π. One thing more, You need to create a dependency injection for your domain service; this modulo should be to isolate any framework with domain module(D of SOLID).
Principal Dependencies¶
container-module(pom.xml) | |
---|---|
Your modules as dependency¶
For this case, you have an app with the follows modules, for instance:
Modules
- blank-application-service
- blank-api
- blank-data-access
- blank-message-core
- blank-external
container-module(pom.xml) | |
---|---|
Plugins to build docker image¶
Using jib plugins prepared for build image. Only, you need to add the plugin.
Tip
The image name is com.blanksystem/blank-service:1.0.0-alpha
Given from maven parent module as groupId/artifactId:version
Also -> com.[system]/[domain]-service:[current_version]
As a final result, you'll have a docker image com.blanksystem/blank-service:1.0.0-alpha
. By default, for Arch AMD.
Also, you can build docker image to Arch AMD using make build_to_amd, or Arch Linux ARM using make build_to_arm
.
----Experimental to AMD----
Integration Test with Lg5Container¶
You need to add the following Dependency and Java classes to your integration test (IT). Recommendation(optional): Remember to create IT in this module for infrastructure components such as input and output ports. For more details, read more about Hexagonal Architecture(Spanish).
Example a Coverage Test Report with Jacoco
Dependencies:
Lg5 tries to simplify dependencies but the power is the same. π
container-module(pom.xml) | |
---|---|
boot/
directory on your test directory.
βββ test/
βββ java/
β βββ com.[blanksystem].[blank].service.container
β βββ boot/
β β βββ Bootstrap.java
β β βββ TestContainersLoader.java
β β βββ TestOrderServiceApplication.java
For create a Bootstrap class has two superclasses:
β If the APP expose any port as:8080
, so you must extend ofLg5TestBoot
class
β Else, extend ofLg5TestBootPortNone
class
Testcontainers during the development time or run the app locally, from Spring Boot
3.1.0
this is possible. Avoid Docker configuration extras like Dockerfiles and others.
all in one click on this class, and you are ready to use the application.
π¨ DO NOT USE FOR PRODUCTION OR LIVING ENVIRONMENTS.
Some TestContainer CustomConfig already to use:
- PostgresContainerCustomConfig
- KafkaContainerCustomConfig
- WiremockContainerCustomConfig
- WireMockGuiContainerCustomConfig
Read more at Lg5Spring Wiki.
When do you like to use some TestContainer
if you use some TestContainer CustomConfig enabled, you would added the following properties for each one:
* Postgres Container
* Kafka Container
* `${kafka-config.bootstrap-servers}`
* SchemaRegistry Container
* `${kafka-config.schema-registry-url}`
* Wiremock Container
* Specify third system url `${wiremock.config.url}`.
* Indicate a port binding to connect: `${wiremock.config.port}`.
* Directory where stored the mock req/res http `${wiremock.config.folder}`.
For instance, in Wiremock Container:
third:
jsonplaceholder:
url: https://jsonplaceholder.typicode.com
basic:
auth:
username: admin
password: pass
feign:
client:
config:
jsonplaceholder:
url: ${third.jsonplaceholder.url}
default:
loggerLevel: FULL
wiremock:
config:
folder: "wiremock/third_system/template.json"
url: "third.jsonplaceholder.url"
port: 7070
Project structure¶
[*] There are Java classes to the test directory.
Logger & ELK¶
This project is prepared to send log files and process visualization with filebeat. You can specify the directory for stored the *.log files. Now, genera two file logs.
Simple log *
[log.path]/[application_name]-simple.log
Complex log *
[log.path]/[application_name]-complex.log
- Specify the directory with
log.path
property.
Simple: Simple details about application logs.
Complex: More details about application logs.
2'DO¶
- Add more Testcontainers custom:
- AWS Services(S3, SQS, SNS...)
- sftp
- third services