Skip to content

Commit

Permalink
feat: allow connection to host network
Browse files Browse the repository at this point in the history
  • Loading branch information
dabg3 committed Mar 28, 2024
1 parent 6a3b186 commit 415ea0e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.stream.Stream;

import org.jboss.logging.Logger;
import org.testcontainers.Testcontainers;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.localstack.LocalStackContainer;
import org.testcontainers.containers.localstack.LocalStackContainer.EnabledService;
Expand Down Expand Up @@ -304,6 +305,10 @@ public String getSecretKey() {
.toArray(EnabledService[]::new))
.withLabel(DEV_SERVICE_LABEL, devServiceName);

if (localStackDevServicesBuildTimeConfig.accessToHost()) {
Testcontainers.exposeHostPorts(localStackDevServicesBuildTimeConfig.hostPort());
}

localStackDevServicesBuildTimeConfig.port().ifPresent(
port -> container.setPortBindings(Collections.singletonList("%s:%s".formatted(port, PORT))));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,17 @@ public interface LocalStackDevServicesBuildTimeConfig {
* Optional fixed port localstack will listen to.
*/
Optional<Integer> port();

/**
* Indicates if the container would make a connection to the host network.
*/
@WithDefault("false")
boolean accessToHost();

/**
* port which the application listen to.
*/
@WithDefault("${quarkus.http.port:8080}")
int hostPort();

}

0 comments on commit 415ea0e

Please sign in to comment.