Skip to content

Commit

Permalink
Added users to main compose and removed unneeeded dependencies. (#85)
Browse files Browse the repository at this point in the history
* Added users to main compose.

* Fixed test crashes

* Fixed payments tests
  • Loading branch information
Ahmad45123 authored May 12, 2024
1 parent 6a7370b commit 93bd412
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 15 deletions.
3 changes: 3 additions & 0 deletions compose.override.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ services:

service_contracts:
image: workup:service_contracts

service_users:
image: workup:service_users
23 changes: 23 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,31 @@ services:
networks:
- contracts

# ----- USERS MICROSERVICE -------
service_users:
image: ahmad45123/workup:service_users
depends_on:
- users_db
- service_mq
networks:
- default
- users
env_file:
- ./services/users/.env

users_db:
image: mongo:7.0
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: user
MONGO_INITDB_ROOT_PASSWORD: password
networks:
- users


networks:
default:
jobs:
payments:
contracts:
users:
4 changes: 0 additions & 4 deletions services/contracts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.workup</groupId>
<artifactId>shared</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class PaymentsApplicationTests {

@Container
static final PostgreSQLContainer<?> postgreSQLContainer =
new PostgreSQLContainer<>("postgres:latest");
new PostgreSQLContainer<>("postgres:12.18");

@Container
static final RabbitMQContainer rabbitMQContainer =
Expand Down
8 changes: 8 additions & 0 deletions services/users/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
USERS_DB_URL=users_db
USERS_DB_PORT=27017
USERS_DB_DB=mydatabase
USERS_DB_USERNAME=user
USERS_DB_PASSWORD=password

USERS_MQ_HOST=service_mq
USERS_SECRET_KEY=j4#BbFGfoc^2k*Bz
5 changes: 0 additions & 5 deletions services/users/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>com.workup</groupId>
<artifactId>shared</artifactId>
Expand Down
8 changes: 4 additions & 4 deletions services/users/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.host=${USERS_DB_URL}
spring.data.mongodb.port=${USERS_DB_PORT}
spring.data.mongodb.database=mydatabase
spring.data.mongodb.username=user
spring.data.mongodb.password=password

spring.rabbitmq.host=localhost
spring.rabbitmq.host=${USERS_MQ_HOST}
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
SECRET_KEY=j4#BbFGfoc^2k*Bz
SECRET_KEY=${USERS_SECRET_KEY}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class UsersApplicationTests {

@Container
static final MongoDBContainer mongoDBContainer =
new MongoDBContainer("mongo:7").withExposedPorts(27017);
new MongoDBContainer("mongo:7.0").withExposedPorts(27017);

@Autowired private AmqpTemplate template;
@Autowired private ClientRepository paymentRequestRepository;
Expand Down Expand Up @@ -72,6 +72,8 @@ static int mongoport() {
@DynamicPropertySource
static void setDatasourceProperties(DynamicPropertyRegistry registry) {
registry.add("spring.data.mongodb.uri", mongoDBContainer::getConnectionString);
registry.add("spring.data.mongodb.host", mongoDBContainer::getHost);
registry.add("spring.data.mongodb.port", mongoDBContainer::getFirstMappedPort);

registry.add("spring.rabbitmq.host", rabbitMQContainer::getHost);
registry.add("spring.rabbitmq.port", rabbitMQContainer::getFirstMappedPort);
Expand Down

0 comments on commit 93bd412

Please sign in to comment.