Skip to content

Commit

Permalink
Fix container start
Browse files Browse the repository at this point in the history
  • Loading branch information
juncevich committed Dec 10, 2023
1 parent 587c999 commit b883f38
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
1 change: 0 additions & 1 deletion chat-service/src/main/resources/application.properties

This file was deleted.

12 changes: 12 additions & 0 deletions chat-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
spring:
data:
mongodb:
username: alex
password: password
host: localhost
port: 27017
database: test
authentication-database: admin

server:
port: 8088
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Bean;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.MongoDBContainer;
//import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.utility.DockerImageName;

import java.util.HashMap;

@TestConfiguration(proxyBeanMethods = false)
public class TestChatServiceApplication {

Expand All @@ -33,7 +33,12 @@ public class TestChatServiceApplication {
@Bean
@ServiceConnection
public MongoDBContainer mongoDBContainer() {
return new MongoDBContainer(DockerImageName.parse("mongo:latest"));
var env = new HashMap<String, String>();
// env.put("MONGO_INITDB_ROOT_USERNAME", "alex");
// env.put("MONGO_INITDB_ROOT_PASSWORD", "Password12345");
env.put("MONGO_DB", "test");
env.put("MONGO_INITDB_DATABASE", "test");
return new MongoDBContainer(DockerImageName.parse("mongo:latest")).withEnv(env).withExposedPorts(27017);
}

public static void main(String[] args) {
Expand Down

0 comments on commit b883f38

Please sign in to comment.