Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/part-9'
Browse files Browse the repository at this point in the history
# Conflicts:
#	discovery-server/src/main/resources/application.properties
#	inventory-service/src/main/java/com/programmingtechie/inventoryservice/service/InventoryService.java
#	inventory-service/src/main/resources/application.properties
#	notification-service/pom.xml
#	order-service/pom.xml
#	product-service/pom.xml
#	product-service/src/main/resources/application.properties
  • Loading branch information
SaiUpadhyayula committed Sep 24, 2022
2 parents b310baf + c7b9106 commit 1f9fd67
Show file tree
Hide file tree
Showing 24 changed files with 283 additions and 40 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@ build/

### VS Code ###
.vscode/

### My SQL Host Data ###
my-sql-data
mongo-data
/mysql_keycloak_data/
/postgres/
/postgres-inventory/
/postgres-order/
4 changes: 4 additions & 0 deletions api-gateway/src/main/resources/application-docker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
server.port=8080
eureka.client.serviceUrl.defaultZone=http://eureka:password@discovery-server:8761/eureka
spring.security.oauth2.resourceserver.jwt.issuer-uri= http://keycloak:8080/realms/spring-boot-microservices-realm
spring.zipkin.base-url=http://zipkin:9411
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server.port=8761
spring.zipkin.base-url=http://zipkin:9411
3 changes: 2 additions & 1 deletion discovery-server/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ server.port=8761
app.eureka.username=eureka
app.eureka.password=password
spring.zipkin.base-url=http://localhost:9411
spring.sleuth.sampler.probability= 1.0
spring.sleuth.sampler.probability=1.0
spring.application.name=discovery-server
163 changes: 163 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,81 @@
---
version: '3'
services:
## MySQL Docker Compose Config
postgres-order:
container_name: postgres-order
image: postgres
environment:
POSTGRES_DB: order-service
POSTGRES_USER: ptechie
POSTGRES_PASSWORD: password
PGDATA: /data/postgres
volumes:
- ./postgres-order:/data/postgres
expose:
- "5431"
ports:
- "5431:5431"
command: -p 5431
restart: unless-stopped

postgres-inventory:
container_name: postgres-inventory
image: postgres
environment:
POSTGRES_DB: inventory-service
POSTGRES_USER: ptechie
POSTGRES_PASSWORD: password
PGDATA: /data/postgres
volumes:
- ./postgres-inventory:/data/postgres
ports:
- "5432:5432"
restart: unless-stopped

## Mongo Docker Compose Config
mongo:
container_name: mongo
image: mongo:4.4.14-rc0-focal
restart: unless-stopped
ports:
- "27017:27017"
expose:
- "27017"
volumes:
- ./mongo-data:/data/db

## Keycloak Config with Mysql database
keycloak-mysql:
container_name: keycloak-mysql
image: mysql:5.7
volumes:
- ./mysql_keycloak_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: keycloak
MYSQL_USER: keycloak
MYSQL_PASSWORD: password

keycloak:
container_name: keycloak
image: quay.io/keycloak/keycloak:18.0.0
command: [ "start-dev", "--import-realm" ]
environment:
DB_VENDOR: MYSQL
DB_ADDR: mysql
DB_DATABASE: keycloak
DB_USER: keycloak
DB_PASSWORD: password
KEYCLOAK_ADMIN: admin
KEYCLOAK_ADMIN_PASSWORD: admin
ports:
- "8080:8080"
volumes:
- ./realms/:/opt/keycloak/data/import/
depends_on:
- keycloak-mysql

zookeeper:
image: confluentinc/cp-zookeeper:7.0.1
container_name: zookeeper
Expand All @@ -23,3 +98,91 @@ services:
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1

## Zipkin
zipkin:
image: openzipkin/zipkin
container_name: zipkin
ports:
- "9411:9411"

## Eureka Server
discovery-server:
image: saiupadhyayula007/discovery-server:latest
container_name: discovery-server
pull_policy: always
ports:
- "8761:8761"
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
- zipkin

api-gateway:
image: saiupadhyayula007/api-gateway:latest
container_name: api-gateway
pull_policy: always
ports:
- "8181:8080"
expose:
- "8181"
environment:
- SPRING_PROFILES_ACTIVE=docker
- LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_SECURITY= TRACE
depends_on:
- zipkin
- discovery-server
- keycloak

## Product-Service Docker Compose Config
product-service:
container_name: product-service
image: saiupadhyayula007/product-service:latest
pull_policy: always
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
- mongo
- discovery-server
- api-gateway

## Order-Service Docker Compose Config
order-service:
container_name: order-service
image: saiupadhyayula007/order-service:latest
pull_policy: always
environment:
- SPRING_PROFILES_ACTIVE=docker
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgres-order:5431/order-service
depends_on:
- postgres-order
- broker
- zipkin
- discovery-server
- api-gateway

## Inventory-Service Docker Compose Config
inventory-service:
container_name: inventory-service
image: saiupadhyayula007/inventory-service:latest
pull_policy: always
environment:
- SPRING_PROFILES_ACTIVE=docker
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgres-inventory:5432/inventory-service
depends_on:
- postgres-inventory
- discovery-server
- api-gateway

## Notification-Service Docker Compose Config
notification-service:
container_name: notification-service
image: saiupadhyayula007/notification-service:latest
pull_policy: always
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
- zipkin
- broker
- discovery-server
- api-gateway
5 changes: 5 additions & 0 deletions inventory-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ public class InventoryService {
@Transactional(readOnly = true)
@SneakyThrows
public List<InventoryResponse> isInStock(List<String> skuCode) {
log.info("Wait Started");
// Thread.sleep(10000);
// log.info("Wait Ended");
log.info("Checking Inventory");
return inventoryRepository.findBySkuCodeIn(skuCode).stream()
.map(inventory ->
InventoryResponse.builder()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
server.port=8080
spring.datasource.url=jdbc:postgresql://postgres:5432/inventory-service
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.username=ptechie
spring.datasource.password=password
spring.zipkin.base-url=http://zipkin:9411
eureka.client.serviceUrl.defaultZone=http://eureka:password@discovery-server:8761/eureka
11 changes: 5 additions & 6 deletions inventory-service/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/inventory-service
spring.datasource.username=root
spring.datasource.password=mysql
spring.jpa.hibernate.ddl-auto=create-drop
server.port=0
spring.datasource.url=jdbc:postgresql://postgres:5432/inventory-service
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.username=ptechie
spring.datasource.password=password
eureka.client.serviceUrl.defaultZone=http://eureka:password@localhost:8761/eureka
spring.application.name=inventory-service

spring.zipkin.base-url=http://localhost:9411
spring.sleuth.sampler.probability= 1.0
spring.sleuth.sampler.probability=1.0
7 changes: 7 additions & 0 deletions inventory-service/src/main/resources/banner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
___ _ ___ _
|_ _| _ _ __ __ ___ _ _ | |_ ___ _ _ _ _ / __| ___ _ _ __ __ (_) __ ___
| | | ' \ \ V / / -_) | ' \ | _| / _ \ | '_| | || | \__ \ / -_) | '_| \ V / | | / _| / -_)
|___| |_||_| \_/ \___| |_||_| \__| \___/ |_| \_, | |___/ \___| |_| \_/ |_| \__| \___|
|__/
${application.title} ${application.version}
Powered by Spring Boot ${spring-boot.version}
1 change: 1 addition & 0 deletions inventory-service/src/main/resources/data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE DATABASE IF NOT EXISTS 'inventory-service';
17 changes: 0 additions & 17 deletions notification-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,4 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
spring.zipkin.base-url=http://zipkin:9411
eureka.client.serviceUrl.defaultZone=http://eureka:password@discovery-server:8761/eureka
spring.kafka.bootstrap-servers=broker:29092
10 changes: 10 additions & 0 deletions order-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand All @@ -68,5 +73,10 @@
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
server.port=8080
spring.datasource.url=jdbc:postgresql://postgres:5431/order-service
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.username=ptechie
spring.datasource.password=password
spring.zipkin.base-url=http://zipkin:9411
eureka.client.serviceUrl.defaultZone=http://eureka:password@discovery-server:8761/eureka
spring.kafka.bootstrap-servers=broker:29092
7 changes: 7 additions & 0 deletions order-service/src/main/resources/banner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
___ _ ___ _
/ _ \ _ _ __| | ___ _ _ / __| ___ _ _ __ __ (_) __ ___
| (_) | | '_| / _` | / -_) | '_| \__ \ / -_) | '_| \ V / | | / _| / -_)
\___/ |_| \__,_| \___| |_| |___/ \___| |_| \_/ |_| \__| \___|

${application.title} ${application.version}
Powered by Spring Boot ${spring-boot.version
1 change: 1 addition & 0 deletions order-service/src/main/resources/data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE DATABASE IF NOT EXISTS 'order-service';
13 changes: 8 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.6</version>
<version>2.7.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand Down Expand Up @@ -64,11 +64,14 @@
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<source>16</source>
<target>16</target>
<from>
<image>eclipse-temurin:17.0.4.1_1-jre</image>
</from>
<to><image>registry.hub.docker.com/saiupadhyayula007/${artifactId}</image></to>
</configuration>
</plugin>
</plugins>
Expand Down
1 change: 0 additions & 1 deletion product-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>

</dependencies>

</project>
Loading

0 comments on commit 1f9fd67

Please sign in to comment.