Skip to content

Commit decaf63

Browse files
committed
fixe the ports!
1 parent acc8a14 commit decaf63

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/test/java/com/testcontainers/TestMain.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@
1212
import org.testcontainers.lifecycle.Startables;
1313
import org.testcontainers.utility.DockerImageName;
1414

15+
import java.io.IOException;
1516
import java.nio.file.Path;
1617
import java.nio.file.Paths;
18+
import java.util.List;
1719
import java.util.Scanner;
1820

1921
import static org.testcontainers.utility.DockerImageName.parse;
2022

2123
public class TestMain {
2224

23-
public static void main(String[] args) {
25+
public static void main(String[] args) throws IOException, InterruptedException {
2426
Network network = Network.newNetwork();
2527

2628
PostgreSQLContainer<?> postgres =
@@ -35,12 +37,13 @@ public static void main(String[] args) {
3537

3638

3739
Path dockerfile = Paths.get("Dockerfile");
40+
41+
;
42+
3843
GenericContainer<?> app = new GenericContainer<>(new ImageFromDockerfile("gatling-demo-app", false)
3944
.withFileFromPath("Dockerfile", Paths.get("Dockerfile"))
4045
.withFileFromPath("target/java-local-development-workshop-0.0.1-SNAPSHOT.jar", Paths.get("target/java-local-development-workshop-0.0.1-SNAPSHOT.jar"))
4146
)
42-
43-
.withExposedPorts(8080)
4447
.withEnv("SPRING_KAFKA_BOOTSTRAP_SERVERS", "BROKER://kafka:9092")
4548
.withEnv("SPRING_DATASOURCE_URL", "jdbc:postgresql://postgres:5432/test")
4649
.withEnv("SPRING_DATASOURCE_USERNAME", "test")
@@ -49,19 +52,22 @@ public static void main(String[] args) {
4952
.withEnv("SPRING_CLOUD_AWS_CREDENTIALS_SECRET-KEY", localStack.getSecretKey())
5053
.withEnv("SPRING_CLOUD_AWS_REGION_STATIC", localStack.getRegion())
5154
.withEnv("SPRING_CLOUD_AWS_ENDPOINT", "localstack:4566")
52-
55+
.withExposedPorts(8080)
5356
.withNetwork(network)
54-
.waitingFor(Wait.forHttp("/actuator/health"))
55-
.withCreateContainerCmdModifier(createContainerCmd -> {
56-
var hostConfig = new HostConfig();
57-
hostConfig.withMemory(1 * 1024L * 1024L);
58-
hostConfig.withCpuCount(1L);
59-
createContainerCmd.withHostConfig(hostConfig);
60-
}
61-
);
57+
.waitingFor(Wait.forHttp("/actuator/health"));
58+
59+
// .withCreateContainerCmdModifier(createContainerCmd -> {
60+
// var hostConfig = new HostConfig();
61+
// hostConfig.withMemory(1024L * 1024L * 1024L);
62+
// hostConfig.withCpuCount(1L);
63+
// createContainerCmd.withHostConfig(hostConfig);
64+
// }
65+
// );
6266

6367
Startables.deepStart(postgres, kafka, localStack).join();
68+
localStack.execInContainer("awslocal", "s3api", "create-bucket", "--bucket product-images");
6469

70+
app.setPortBindings(List.of("8080:8080"));
6571
app.start();
6672

6773
CloudflaredContainer cloudflaredContainer = new CloudflaredContainer(parse("cloudflare/cloudflared"), app.getMappedPort(8080));

0 commit comments

Comments
 (0)