diff --git a/common/deployment/src/main/java/io/quarkus/amazon/common/deployment/DevServicesLocalStackProcessor.java b/common/deployment/src/main/java/io/quarkus/amazon/common/deployment/DevServicesLocalStackProcessor.java index a19a98ec4..9ba024e76 100644 --- a/common/deployment/src/main/java/io/quarkus/amazon/common/deployment/DevServicesLocalStackProcessor.java +++ b/common/deployment/src/main/java/io/quarkus/amazon/common/deployment/DevServicesLocalStackProcessor.java @@ -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; @@ -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)))); diff --git a/common/runtime/src/main/java/io/quarkus/amazon/common/runtime/LocalStackDevServicesBuildTimeConfig.java b/common/runtime/src/main/java/io/quarkus/amazon/common/runtime/LocalStackDevServicesBuildTimeConfig.java index e7bd794c5..c295c4a2d 100644 --- a/common/runtime/src/main/java/io/quarkus/amazon/common/runtime/LocalStackDevServicesBuildTimeConfig.java +++ b/common/runtime/src/main/java/io/quarkus/amazon/common/runtime/LocalStackDevServicesBuildTimeConfig.java @@ -48,4 +48,17 @@ public interface LocalStackDevServicesBuildTimeConfig { * Optional fixed port localstack will listen to. */ Optional 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(); + }