From 6427b385b58a005f4d083fd37712d8b38b2990ae Mon Sep 17 00:00:00 2001 From: dagrammy Date: Fri, 1 Mar 2024 23:04:57 +0100 Subject: [PATCH] feat: Devservice localstack port (#1155) * This update includes the ability to set an optional fixed port for LocalStack in Quarkus AWS DevServices. * Fixed formatting --- .../DevServicesLocalStackProcessor.java | 3 +++ .../LocalStackDevServicesBuildTimeConfig.java | 5 +++++ ...al-stack-dev-services-build-time-config.adoc | 17 +++++++++++++++++ 3 files changed, 25 insertions(+) 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 04b9450d8..a19a98ec4 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 @@ -304,6 +304,9 @@ public String getSecretKey() { .toArray(EnabledService[]::new)) .withLabel(DEV_SERVICE_LABEL, devServiceName); + localStackDevServicesBuildTimeConfig.port().ifPresent( + port -> container.setPortBindings(Collections.singletonList("%s:%s".formatted(port, PORT)))); + localStackDevServicesBuildTimeConfig.initScriptsFolder().ifPresentOrElse(initScriptsFolder -> { container.withFileSystemBind(initScriptsFolder, "/etc/localstack/init/ready.d", BindMode.READ_ONLY); }, () -> localStackDevServicesBuildTimeConfig.initScriptsClasspath().ifPresent(resourcePath -> { 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 a811de823..e7bd794c5 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 @@ -43,4 +43,9 @@ public interface LocalStackDevServicesBuildTimeConfig { * you want is not covered by the extension */ Map additionalServices(); + + /** + * Optional fixed port localstack will listen to. + */ + Optional port(); } diff --git a/docs/modules/ROOT/pages/includes/quarkus-aws-devservices-localstack-local-stack-dev-services-build-time-config.adoc b/docs/modules/ROOT/pages/includes/quarkus-aws-devservices-localstack-local-stack-dev-services-build-time-config.adoc index ab3b1a445..24338c7d4 100644 --- a/docs/modules/ROOT/pages/includes/quarkus-aws-devservices-localstack-local-stack-dev-services-build-time-config.adoc +++ b/docs/modules/ROOT/pages/includes/quarkus-aws-devservices-localstack-local-stack-dev-services-build-time-config.adoc @@ -78,6 +78,23 @@ endif::add-copy-button-to-env-var[] | +a|icon:lock[title=Fixed at build time] [[quarkus-aws-devservices-localstack-local-stack-dev-services-build-time-config_quarkus-aws-devservices-localstack-port]]`link:#quarkus-aws-devservices-localstack-local-stack-dev-services-build-time-config_quarkus-aws-devservices-localstack-port[quarkus.aws.devservices.localstack.port]` + + +[.description] +-- +Optional fixed port localstack will listen to. + +ifdef::add-copy-button-to-env-var[] +Environment variable: env_var_with_copy_button:+++QUARKUS_AWS_DEVSERVICES_LOCALSTACK_PORT+++[] +endif::add-copy-button-to-env-var[] +ifndef::add-copy-button-to-env-var[] +Environment variable: `+++QUARKUS_AWS_DEVSERVICES_LOCALSTACK_PORT+++` +endif::add-copy-button-to-env-var[] +--|int +| + + a|icon:lock[title=Fixed at build time] [[quarkus-aws-devservices-localstack-local-stack-dev-services-build-time-config_quarkus-aws-devservices-localstack-container-properties-container-properties]]`link:#quarkus-aws-devservices-localstack-local-stack-dev-services-build-time-config_quarkus-aws-devservices-localstack-container-properties-container-properties[quarkus.aws.devservices.localstack.container-properties]`