Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Dockerfile

This file was deleted.

25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ Misc:
- Cache implemented
- Zipkin tracing
- Websocket implemented to show article/comment review status/notifications..
- Docker-compose deploy/kubernetes

Future: do more stuff
- CQRS with event store/streaming
- Spring Cloud Contract integration (WIP)
- Docker-compose deploy/kubernetes
- Visitors log - IP, browser, etc
- Centralized error reporting
- Geo-Spatial query for visitors
Expand All @@ -87,7 +87,7 @@ Future: do more stuff
- JfrUnit ( WIP )
-
### Requirements
- JDK 17+
- JDK 21+
- Lombok configured on IDE
- http://ganeshtiwaridotcomdotnp.blogspot.com/2016/03/configuring-lombok-on-intellij.html
- For eclipse, download the lombok jar, run it, and point to eclipse installation
Expand All @@ -96,7 +96,17 @@ Future: do more stuff
- Make sure docker is started and running
- Run `$ sudo chmod 666 /var/run/docker.sock` if you get error like this "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? (Details: [13] Permission denied)"

#### How to Run

## Build and create docker image

`sh build-docker-images.sh`

## Run all apps and dependencies using docker-compose

- Run ```docker compose -f docker/docker-compose.yml up``` at root to run all apps and dependencies and open localhost:8081 to access main app


## How to Run apps individually

It contains following applications:

Expand All @@ -110,21 +120,18 @@ It contains following applications:

Option 1 - run with manually started KeyCloak, ActiveMQ and MySQL servers
- Run ```mvn clean install``` at root
- Run ```docker-compose -f config/docker-compose.yml up``` at root to start docker containers
- Run ```docker compose -f docker/docker-compose-dev.yml up``` at root to start docker containers
- Go to main-app folder and run ```mvn``` to start the application

Option 2 - automatically start KeyCloak, ActiveMQ and MySQL using TestContainer while application is starting
- Run ```mvn clean install``` at root
- Go to main-app folder and run ```mvn -Pdev,withTestContainer``` to start the application

Option 3 - run from IDE
Option 2 - run from IDE
- import into your IDE and compile the full project and run the Application.java on main-app module
- Update run configuration to run maven goal `wro4j:run` Before Launch. It should be after 'Build'


## Run Tests (use ./mvnw instead of mvn if you want to use maven wrapper)

## It uses TestContainers, which requires Docker to be installed locally.
Test uses TestContainers, which requires Docker to be installed locally.

##### Running full tests

Expand Down
14 changes: 14 additions & 0 deletions build-docker-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

# full build with 5 threads
./mvnw -T 5 clean package install

# create docker images out of build jar files using spring boot and packeto
./mvnw spring-boot:build-image-no-fork -pl content-checker/content-checker-service
./mvnw spring-boot:build-image-no-fork -pl email/email-service
./mvnw spring-boot:build-image-no-fork -pl trend/trend-service
./mvnw spring-boot:build-image-no-fork -pl main-app/main-webapp
./mvnw spring-boot:build-image-no-fork -pl main-app/report-service

# list
docker image ls | grep gtapp
23 changes: 9 additions & 14 deletions content-checker/content-checker-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<imageName>gtapp-${project.name}</imageName>
<layers>
<enabled>true</enabled>
</layers>
</configuration>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
Expand All @@ -95,10 +101,7 @@
<profiles>

<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<id>local</id>
<dependencies>
<dependency>
<groupId>org.springdoc</groupId>
Expand All @@ -108,16 +111,8 @@
</dependency>
</dependencies>
<properties>
<spring.profiles.active>dev</spring.profiles.active>
<build.profile>dev</build.profile>
</properties>
</profile>

<profile>
<id>prod</id>
<properties>
<spring.profiles.active>prod</spring.profiles.active>
<build.profile>prod</build.profile>
<spring.profiles.active>local</spring.profiles.active>
<build.profile>local</build.profile>
</properties>
</profile>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
spring:
profiles:
active: dev
active: local

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ spring:
# Otherwise, it will be filled in by maven when building the WAR file
# Either way, it can be overridden by `--spring.profiles.active` value passed in the commandline or `-Dspring.profiles.active` set in `JAVA_OPTS`
active: '@spring.profiles.active@'
artemis:
user: ${ACTIVEMQ_ARTEMIS_USER:admin}
password: ${ACTIVEMQ_ARTEMIS_PASSWORD:admin}
broker-url: tcp://${ACTIVEMQ_ARTEMIS_HOST:localhost}:${ACTIVEMQ_ARTEMIS_PORT:61616}


server:
port: 8083
Expand All @@ -24,7 +29,7 @@ management:
probability: 1.0
zipkin:
tracing:
endpoint: http://localhost:9411/api/v2/spans
endpoint: http://${ZIPKIN_HOST:localhost}:${ZIPKIN_PORT:9411}/api/v2/spans
health:
jms:
enabled: true
18 changes: 9 additions & 9 deletions config/docker-compose.yml → docker/docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# use this to run dependencies like activemq, email, mysql, keycloak using docker for DEVELOPMENT
version: '3'
services:
activemq_artemis:
Expand All @@ -12,7 +13,7 @@ services:
- 8161:8161 # use this to access from browser
- 61616:61616
networks:
- seedappnet
- gtapp-network
mysql:
image: 'mysql'
environment:
Expand All @@ -22,22 +23,22 @@ services:
- 3306:3306
command: mysqld --lower_case_table_names=1 --character_set_server=utf8mb4 --explicit_defaults_for_timestamp
networks:
- seedappnet
- gtapp-network
emailhog:
image: 'richarvey/mailhog'
container_name: mailhog
ports:
- 1025:1025
- 8025:8025 # use this to access from browser
networks:
- seedappnet
- gtapp-network
zipkin:
image: 'openzipkin/zipkin'
container_name: zipkin
ports:
- 9411:9411
networks:
- seedappnet
- gtapp-network
keycloak:
image: 'quay.io/keycloak/keycloak:25.0.6'
container_name: keycloak
Expand All @@ -53,18 +54,17 @@ services:
volumes:
- ../main-app/main-webapp/src/main/resources/keycloak/:/opt/keycloak/data/import
ports:
- 8082:8080
- 8080:8080
- 9443:9443
networks:
- seedappnet
- gtapp-network
volumes:
esdata1:
driver: local
networks:
seedappnet:
gtapp-network:
driver: bridge


#run using
#docker-compose -f docker-compose.yml up
# or just docker-compose up
#docker compose -f docker-compose-dev.yml up
99 changes: 99 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
version: '3'
services:
localhost: #expose all container ports so they can use services using localhost:PORT
image: alpine:latest
command: sleep infinity
ports:
- "8080:8080"
- "8161:8161"
- "3306:3306"
- "1025:1025"
- "8025:8025"
- "9411:9411"
- "8081:8081"
- "8083:8083"
- "8084:8084"
- "8085:8085"
- "8086:8086"
- "8161:8161"
- "61616:61616"
activemq:
# its not supported in M1 Mac, workaround is to enable Rosetta in Docker
# Docker settings → Features in development → check ☑ Use Rosetta for x86/amd64 emulation on Apple Silicon, and then restart Docker.
image: 'apache/activemq-artemis:2.37.0'
environment:
- "ARTEMIS_USER=admin"
- "ARTEMIS_PASSWORD=admin"
network_mode: "service:localhost"
mysql:
image: 'mysql'
environment:
- "MYSQL_USER=seedappuser"
- "MYSQL_ROOT_PASSWORD=password"
- "MYSQL_DATABASE=seedapp"
command: mysqld --lower_case_table_names=1 --character_set_server=utf8mb4 --explicit_defaults_for_timestamp
network_mode: "service:localhost"
emailhog:
image: 'richarvey/mailhog'
network_mode: "service:localhost"
zipkin:
image: 'openzipkin/zipkin'
network_mode: "service:localhost"
keycloak:
image: 'quay.io/keycloak/keycloak:25.0.6'
command: start-dev --import-realm
environment:
- "KEYCLOAK_DB=dev-file"
- "KEYCLOAK_ADMIN=admin"
- "KEYCLOAK_ADMIN_PASSWORD=admin"
- "KEYCLOAK_FEATURES=scripts"
- "KEYCLOAK_HTTP_PORT=8080"
- "KEYCLOAK_HTTPS_PORT=9443"
volumes:
- ../main-app/main-webapp/src/main/resources/keycloak/:/opt/keycloak/data/import
network_mode: "service:localhost"
content-checker-service:
image: gtapp-content-checker-service:latest
environment:
- "ZIPKIN_HOST=zipkin"
network_mode: "service:localhost"
depends_on:
- zipkin
- activemq
email-service:
image: gtapp-email-service:latest
environment:
- "SPRING_PROFILES_ACTIVE=prod"
network_mode: "service:localhost"
depends_on:
- emailhog
- zipkin
trend-service:
image: gtapp-trend-service:latest
environment:
- "SPRING_PROFILES_ACTIVE=prod"
network_mode: "service:localhost"
depends_on:
- zipkin
report-service:
image: gtapp-report-service:latest
environment:
- "SPRING_PROFILES_ACTIVE=prod"
network_mode: "service:localhost"
depends_on:
- zipkin
- mysql
- keycloak
main-webapp:
image: gtapp-main-webapp:latest
environment:
- "SPRING_PROFILES_ACTIVE=prod"
network_mode: "service:localhost"
depends_on:
- zipkin
- email-service
- mysql
- activemq
- keycloak
volumes:
- /var/tmp/:/tmp/uploads/attachments/
28 changes: 6 additions & 22 deletions email/email-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<imageName>gtapp-${project.name}</imageName>
<layers>
<enabled>true</enabled>
</layers>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.cloud</groupId>
Expand Down Expand Up @@ -138,26 +144,4 @@
</plugins>
</build>

<profiles>

<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<spring.profiles.active>dev</spring.profiles.active>
<build.profile>dev</build.profile>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<spring.profiles.active>prod</spring.profiles.active>
<build.profile>prod</build.profile>
</properties>
</profile>

</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
spring:
profiles:
active: dev
active: local
4 changes: 2 additions & 2 deletions email/email-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ spring:
# Either way, it can be overridden by `--spring.profiles.active` value passed in the commandline or `-Dspring.profiles.active` set in `JAVA_OPTS`
active: '@spring.profiles.active@'
mail:
host: localhost
host: ${MAILHOG_HOST:localhost}
port: ${MAILHOG_PORT:1025}
username:
password:
Expand All @@ -31,6 +31,6 @@ management:
probability: 1.0
zipkin:
tracing:
endpoint: http://localhost:9411/api/v2/spans
endpoint: http://${ZIPKIN_HOST:localhost}:${ZIPKIN_PORT:9411}/api/v2/spans


2 changes: 1 addition & 1 deletion email/email-service/src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spring:
oauth2:
resourceserver:
jwt:
issuer-uri: http://localhost:${KEYCLOAK_PORT:8082}/realms/articleapp
issuer-uri: http://localhost:${KEYCLOAK_PORT:8080}/realms/articleapp
logging.level:
ROOT: WARN
gt: INFO
Expand Down
Loading
Loading