Skip to content

Commit 5d765f3

Browse files
committed
update ecommerce
1 parent 4fd0ef5 commit 5d765f3

File tree

214 files changed

+5600
-50770
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+5600
-50770
lines changed

.env

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# ******************
2+
# postgres
3+
# ******************
4+
POSTGRES_VERSION=16.3
5+
POSTGRES_USER=admin
6+
POSTGRES_PASSWORD=admin
7+
POSTGRES_HOSTNAME=postgres
8+
POSTGRES_HOST=5432
9+
POSTGRES_PORT=5434
10+
DB_HOST=localhost
11+
12+
# ******************
13+
# pgadmin
14+
# ******************
15+
PGADMIN_VERSION=8.8
16+
PGADMIN_DEFAULT_EMAIL=admin@ezbuy.com
17+
PGADMIN_DEFAULT_PASSWORD=admin
18+
PGADMIN_LISTEN_PORT=5050
19+
20+
# ******************
21+
# keycloak
22+
# ******************
23+
KEYCLOAK_VERSION=25.0.2
24+
KEYCLOAK_PORT=8080
25+
KC_HTTP_PORT=8080
26+
KC_HTTPS_PORT=8443
27+
KEYCLOAK_ADMIN=admin
28+
KEYCLOAK_ADMIN_PASSWORD=admin
29+
KEYCLOAK_CLIENT_ID=ezbuy-client
30+
KEYCLOAK_CLIENT_SECRET=mI92QDfvi20tZgFtjpRAPWu8TR6eMHmw
31+
KEYCLOAK_REALM=ezbuy-server
32+
KEYCLOAK_SERVER_URL=http://localhost:8080
33+
KEYCLOAK_GRANT_TYPE=password
34+
KEYCLOAK_HOST=localhost
35+
36+
# ******************
37+
# minio
38+
# ******************
39+
MINIO_VERSION=RELEASE.2024-08-03T04-33-23Z
40+
MINIO_ROOT_USER=admin
41+
MINIO_ROOT_PASSWORD=tienha@!@#
42+
MINIO_PORT=9001
43+
44+
# ******************
45+
# Kafka
46+
# ******************
47+
KAFKA_VERSION=7.7.0
48+
KAFKA_SERVICE_HOST=kafka
49+
KAFKA_SERVICE_PORT=9092
50+
KAFKA_SERVICE_ADDR=kafka:${KAFKA_SERVICE_PORT}
51+
KAFKA_BROKER_ID=1
52+
KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
53+
KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://${KAFKA_SERVICE_ADDR},PLAINTEXT_HOST://kafka:29092
54+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
55+
KAFKA_INTER_BROKER_LISTENER_NAME=PLAINTEXT
56+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1
57+
58+
# ******************
59+
# Kafka Connect
60+
# ******************
61+
KAFKA_CONNECT_VERSION=3.0
62+
63+
# ******************
64+
# Zookeeper
65+
# ******************
66+
ZOOKEEPER_VERSION=3.0
67+
68+
# ******************
69+
# elasticsearch
70+
# ******************
71+
ELASTIC_VERSION=8.15.0
72+
#Passwords for stack users
73+
# User 'elastic' (built-in)
74+
ELASTIC_PASSWORD='tienha@!@#'
75+
76+
# User 'logstash_internal' (custom)
77+
# The user Logstash uses to connect and send data to Elasticsearch.
78+
LOGSTASH_INTERNAL_PASSWORD='tienha@!@#'
79+
80+
# User 'kibana_system' (built-in)
81+
# The user Kibana uses to connect and communicate with Elasticsearch.
82+
KIBANA_SYSTEM_PASSWORD='tienha@!@#'
83+
84+
# Users 'metricbeat_internal', 'filebeat_internal' and 'heartbeat_internal' (custom)
85+
# The users Beats use to connect and send data to Elasticsearch.
86+
METRICBEAT_INTERNAL_PASSWORD=''
87+
FILEBEAT_INTERNAL_PASSWORD=''
88+
HEARTBEAT_INTERNAL_PASSWORD=''
89+
90+
# User 'monitoring_internal' (custom)
91+
# The user Metricbeat uses to collect monitoring data from stack components.
92+
MONITORING_INTERNAL_PASSWORD=''
93+
94+
# User 'beats_system' (built-in)
95+
# The user the Beats use when storing monitoring information in Elasticsearch.
96+
BEATS_SYSTEM_PASSWORD=''
97+
98+
# ******************
99+
# Swagger UI
100+
# ******************
101+
SWAGGER_VERSION=v5.17.14
102+
URLS=[{ url: 'http://api.ezbuy.local/product/v3/api-docs', name: 'Product' },{ url: 'http://api.ezbuy.local/media/v3/api-docs', name: 'Media' },{ url: 'http://api.ezbuy.local/customer/v3/api-docs', name: 'Customer' },{ url: 'http://api.ezbuy.local/cart/v3/api-docs', name: 'Cart'},{ url: 'http://api.ezbuy.local/rating/v3/api-docs', name: 'Rating' }, { url: 'http://api.ezbuy.local/order/v3/api-docs', name: 'Order'},{ url: 'http://api.ezbuy.local/payment/v3/api-docs', name: 'Payment'},{ url: 'http://api.ezbuy.local/payment-paypal/v3/api-docs', name: 'Payment-paypal'},{ url: 'http://api.ezbuy.local/location/v3/api-docs', name: 'Location'}, { url: 'http://api.ezbuy.local/inventory/v3/api-docs', name: 'Inventory'},{ url: 'http://api.ezbuy.local/tax/v3/api-docs', name: 'Tax' },{ url: 'http://api.ezbuy.local/promotion/v3/api-docs', name: 'Promotion'},{ url: 'http://api.ezbuy.local/search/v3/api-docs', name: 'Search'}]
103+
104+
# ******************
105+
# Redis Connect
106+
# ******************
107+
REDIS_VERSION=7.4.0
108+
REDIS_USER=default
109+
REDIS_PASSWORD=tienha@!@#
110+
REDIS_PORT=6379
111+
REDIS_DATABASES=16
112+
113+
# ******************
114+
# RedisInsight Connect
115+
# ******************
116+
REDIS_INSIGHT_VERSION=2.54.0
117+
118+
# ******************
119+
# Kong-Gateway
120+
# ******************
121+
KONG_GATEWAY_VERSION=3.4

common-lib/pom.xml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>com.hoangtien2k3</groupId>
7+
<artifactId>ecommerce-microservices</artifactId>
8+
<version>${revision}</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>common-lib</artifactId>
12+
<version>${revision}</version>
13+
<packaging>jar</packaging>
14+
15+
<name>Common Library</name>
16+
<description>Ecommerce Common Library service</description>
17+
18+
<properties>
19+
20+
</properties>
21+
22+
<dependencies>
23+
<dependency>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-starter-oauth2-authorization-server</artifactId>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter-web</artifactId>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.springframework.boot</groupId>
33+
<artifactId>spring-boot-starter-aop</artifactId>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.springframework.boot</groupId>
37+
<artifactId>spring-boot-starter-data-jpa</artifactId>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.springframework</groupId>
41+
<artifactId>spring-tx</artifactId>
42+
</dependency>
43+
44+
<!-- Kafka Dependencies -->
45+
<dependency>
46+
<groupId>org.springframework.kafka</groupId>
47+
<artifactId>spring-kafka</artifactId>
48+
</dependency>
49+
<!-- <dependency>-->
50+
<!-- <groupId>com.opencsv</groupId>-->
51+
<!-- <artifactId>opencsv</artifactId>-->
52+
<!-- <version>${opencsv.version}</version>-->
53+
<!-- </dependency>-->
54+
55+
<!-- Test Dependency -->
56+
<dependency>
57+
<groupId>org.testcontainers</groupId>
58+
<artifactId>kafka</artifactId>
59+
<scope>test</scope>
60+
</dependency>
61+
</dependencies>
62+
63+
<build>
64+
<plugins>
65+
<plugin>
66+
<groupId>org.apache.maven.plugins</groupId>
67+
<artifactId>maven-compiler-plugin</artifactId>
68+
</plugin>
69+
<plugin>
70+
<groupId>org.jacoco</groupId>
71+
<artifactId>jacoco-maven-plugin</artifactId>
72+
</plugin>
73+
<plugin>
74+
<groupId>org.apache.maven.plugins</groupId>
75+
<artifactId>maven-jar-plugin</artifactId>
76+
<executions>
77+
<execution>
78+
<goals>
79+
<goal>test-jar</goal>
80+
</goals>
81+
</execution>
82+
</executions>
83+
</plugin>
84+
</plugins>
85+
</build>
86+
87+
</project>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package common.container;
2+
3+
import dasniko.testcontainers.keycloak.KeycloakContainer;
4+
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.test.context.DynamicPropertyRegistry;
7+
import org.testcontainers.containers.KafkaContainer;
8+
import org.testcontainers.containers.PostgreSQLContainer;
9+
import org.testcontainers.utility.DockerImageName;
10+
11+
/**
12+
* Factory class that holds and provides containers used for testing with Testcontainers.
13+
*/
14+
public final class ContainerFactory {
15+
16+
private ContainerFactory() {}
17+
18+
public static KeycloakContainer keycloakContainer(DynamicPropertyRegistry registry) {
19+
KeycloakContainer keycloak = new KeycloakContainer()
20+
.withRealmImportFiles("/test-realm.json")
21+
.withReuse(true);
22+
23+
registry.add(
24+
"spring.security.oauth2.resourceserver.jwt.issuer-uri",
25+
() -> "%s%s".formatted(keycloak.getAuthServerUrl(), "/realms/quarkus")
26+
);
27+
registry.add(
28+
"spring.security.oauth2.resourceserver.jwt.jwk-set-uri",
29+
() -> "%s%s".formatted(keycloak.getAuthServerUrl(), "/realms/quarkus/protocol/openid-connect/certs")
30+
);
31+
return keycloak;
32+
}
33+
34+
public static KafkaContainer kafkaContainer(DynamicPropertyRegistry registry, String version) {
35+
var kafkaContainer = new KafkaContainer(
36+
DockerImageName.parse("confluentinc/cp-kafka:%s".formatted(version))
37+
);
38+
registry.add("spring.kafka.bootstrap-servers", kafkaContainer::getBootstrapServers);
39+
registry.add("bootstrap.servers", kafkaContainer::getBootstrapServers);
40+
41+
// Consumer properties
42+
registry.add("auto.offset.reset", () -> "earliest");
43+
registry.add("spring.kafka.producer.bootstrap-servers", kafkaContainer::getBootstrapServers);
44+
45+
// Producer properties
46+
registry.add("spring.kafka.consumer.bootstrap-servers", kafkaContainer::getBootstrapServers);
47+
return kafkaContainer;
48+
}
49+
50+
public static PostgreSQLContainer pgvector(DynamicPropertyRegistry registry, String version) {
51+
var image = DockerImageName.parse("pgvector/pgvector:%s".formatted(version))
52+
.asCompatibleSubstituteFor("postgres");
53+
var postgres = new PostgreSQLContainer<>(image);
54+
postgres.start();
55+
56+
registry.add("spring.datasource.url", postgres::getJdbcUrl);
57+
registry.add("spring.datasource.username", postgres::getUsername);
58+
registry.add("spring.datasource.password", postgres::getPassword);
59+
return postgres;
60+
}
61+
62+
}

0 commit comments

Comments
 (0)