Skip to content

Commit

Permalink
containerized app
Browse files Browse the repository at this point in the history
  • Loading branch information
shelajev committed Sep 23, 2024
1 parent 1992f8a commit 3e9d4e9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 67 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM azul/zulu-openjdk:17-latest
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
18 changes: 13 additions & 5 deletions src/test/java/com/testcontainers/catalog/ContainersConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.testcontainers.utility.DockerImageName.parse;

import com.testcontainers.catalog.domain.FileStorageService;
import net.bytebuddy.asm.Advice;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
Expand All @@ -11,33 +12,40 @@
import org.springframework.test.context.DynamicPropertyRegistry;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.KafkaContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.containers.localstack.LocalStackContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.elasticsearch.ElasticsearchContainer;
import org.testcontainers.lifecycle.Startables;
import org.testcontainers.utility.MountableFile;

@TestConfiguration(proxyBeanMethods = false)
public class ContainersConfig {

static Network network = Network.newNetwork();

@Bean
@ServiceConnection
PostgreSQLContainer<?> postgresContainer() {
PostgreSQLContainer<?> selfPostgreSQLContainer =
new PostgreSQLContainer<>(parse("postgres:16-alpine"));


new PostgreSQLContainer<>(parse("postgres:16-alpine"))
.withNetwork(network).withNetworkAliases("postgres");
return selfPostgreSQLContainer;
}

@Bean
@ServiceConnection
KafkaContainer kafkaContainer() {
return new KafkaContainer(parse("confluentinc/cp-kafka:7.5.0")).withReuse(true);
return new KafkaContainer(parse("confluentinc/cp-kafka:7.5.0"))
.withReuse(true).withNetwork(network).withNetworkAliases("kafka");

}

@Bean("localstackContainer")
LocalStackContainer localstackContainer(DynamicPropertyRegistry registry) {
LocalStackContainer localStack = new LocalStackContainer(parse("localstack/localstack:2.3")).withReuse(true);
LocalStackContainer localStack = new LocalStackContainer(parse("localstack/localstack:2.3"))
.withNetwork(network).withNetworkAliases("localstack").withReuse(true);
registry.add("spring.cloud.aws.credentials.access-key", localStack::getAccessKey);
registry.add("spring.cloud.aws.credentials.secret-key", localStack::getSecretKey);
registry.add("spring.cloud.aws.region.static", localStack::getRegion);
Expand Down

This file was deleted.

0 comments on commit 3e9d4e9

Please sign in to comment.