diff --git a/src/main/java/cloud/localstack/docker/annotation/LocalstackDockerAnnotationProcessor.java b/src/main/java/cloud/localstack/docker/annotation/LocalstackDockerAnnotationProcessor.java index d904f9f..c55f594 100644 --- a/src/main/java/cloud/localstack/docker/annotation/LocalstackDockerAnnotationProcessor.java +++ b/src/main/java/cloud/localstack/docker/annotation/LocalstackDockerAnnotationProcessor.java @@ -36,12 +36,16 @@ private LocalstackDockerConfiguration processDockerPropertiesAnnotation(Localsta .ignoreDockerRunErrors(properties.ignoreDockerRunErrors()) .randomizePorts(properties.randomizePorts()) .imageTag(StringUtils.isEmpty(properties.imageTag()) ? null : properties.imageTag()) - .portEdge(properties.portEdge()) - .portElasticSearch(properties.portElasticSearch()) + .portEdge(getEnvOrDefault("LOCALSTACK_EDGE_PORT", properties.portEdge())) + .portElasticSearch(getEnvOrDefault("LOCALSTACK_ELASTICSEARCH_PORT", properties.portElasticSearch())) .useSingleDockerContainer(properties.useSingleDockerContainer()) .build(); } + private String getEnvOrDefault(final String environmentVariable, final String defaultValue) { + return System.getenv().getOrDefault(environmentVariable, defaultValue); + } + private Map getCustomPortMappings(final LocalstackDockerProperties properties) { final Map portMappings = new HashMap<>(); for (String service : properties.services()) { diff --git a/src/main/java/cloud/localstack/docker/annotation/LocalstackDockerProperties.java b/src/main/java/cloud/localstack/docker/annotation/LocalstackDockerProperties.java index 1094ae7..951c9da 100644 --- a/src/main/java/cloud/localstack/docker/annotation/LocalstackDockerProperties.java +++ b/src/main/java/cloud/localstack/docker/annotation/LocalstackDockerProperties.java @@ -52,12 +52,14 @@ String imageTag() default ""; /** - * Port number for the edge service, the main entry point for all API invocations + * Port number for the edge service, the main entry point for all API invocations. Alternatively, use the + * LOCALSTACK_EDGE_PORT environment variable. */ String portEdge() default "4566"; /** - * Port number for the elasticsearch service + * Port number for the elasticsearch service. Alternatively, use the LOCALSTACK_ELASTICSEARCH_PORT environment + * variable. */ String portElasticSearch() default "4571";