2

On the Jhipster Registry page, it's mention that we can set the Git repository for Spring Cloud Config via the following parameters.

--spring.profiles.active=prod --spring.security.user.password=admin --jhipster.security.authentication.jwt.secret=secret-key --spring.cloud.config.server.composite=https://github.com/jhipster/jhipster-registry-sample-config --spring.cloud.config.server.composite[0].type=git --spring.cloud.config.server.composite[0].uri=https://github.com/jhipster/jhipster-registry-sample-config

But I would like to setup those parameters via environment variables in my docker-compose, how can I achieve this ? Particularly this one : spring.cloud.config.server.composite[0].uri with the square brackets.

Update

I tried the spelling defined in the answer of Gaël Marziou, but it didn't work. Here is the docker jhipster-registry.yml that I'm using, generated with jhipster docker-compose subgenerator, in which I added the Spring Cloud Config

version: '2'
services:
    jhipster-registry:
        image: jhipster/jhipster-registry
        environment:
        - SPRING_PROFILES_ACTIVE=prod,git
        - SPRING_SECURITY_USER_PASSWORD=admin
        - JHIPSTER_REGISTRY_PASSWORD=admin
        - JHIPSTER_LOGGING_LOGSTASH_ENABLED=true
        - JHIPSTER_LOGGING_LOGSTASH_HOST=jhipster-logstash
        - JHIPSTER_METRICS_LOGS_ENABLED=true
        - JHIPSTER_METRICS_LOGS_REPORTFREQUENCY=60
        - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE=https://github.com/anthonyrichir/demo-feign-config
        - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_TYPE=git
        - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_URI=https://github.com/anthonyrichir/demo-feign-config
        ports:
        - 8761:8761

With this config, the registry says:

Failed to bind properties under 'spring.cloud.config.server.composite' to java.util.List<java.util.Map<java.lang.String, java.lang.Object>>:

    Reason: No converter found capable of converting from type [java.lang.String] to type [java.util.List<java.util.Map<java.lang.String, java.lang.Object>>]

I also tried this configuration:

version: '2'
services:
    jhipster-registry:
        image: jhipster/jhipster-registry
        environment:
        - SPRING_PROFILES_ACTIVE=prod,git
        - SPRING_SECURITY_USER_PASSWORD=admin
        - JHIPSTER_REGISTRY_PASSWORD=admin
        - JHIPSTER_LOGGING_LOGSTASH_ENABLED=true
        - JHIPSTER_LOGGING_LOGSTASH_HOST=jhipster-logstash
        - JHIPSTER_METRICS_LOGS_ENABLED=true
        - JHIPSTER_METRICS_LOGS_REPORTFREQUENCY=60
        - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_TYPE=git
        - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_URI=https://github.com/anthonyrichir/demo-feign-config
        ports:
        - 8761:8761

I get this error:

Caused by: java.lang.IllegalStateException: You need to configure a uri for the git repository
    at org.springframework.util.Assert.state(Assert.java:73)
    at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.afterPropertiesSet(JGitEnvironmentRepository.java:245)
    at org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.afterPropertiesSet(MultipleJGitEnvironmentRepository.java:69)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1767)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1704)
    ... 88 common frames omitted
Anthony Richir
  • 649
  • 2
  • 8
  • 31
  • Make sure to use the latest version of the registry (4.0.0 I think) which uses the composite properties: ```jhipster-registry: image: jhipster/jhipster-registry:v4.0.0``` – Pierre Besson Aug 17 '18 at 14:26
  • I added the version, but it was already using it, and so I still get the same error – Anthony Richir Aug 17 '18 at 18:44
  • Note that I also tried to generate a new monolith with latest Jhipster (5.2.1), than generate the docker-compose and jhipster-registry.yml still mention GIT_URI in comments. I would be nice to fix this, and also add some details about this in the documentation. Should I open an issue on Github ? – Anthony Richir Aug 17 '18 at 18:59
  • Oh it seems you forgot to add the "composite" spring profile. – Pierre Besson Aug 18 '18 at 21:50
  • Looks like we have overlooked to add it for monolith config, please open an issue with your exact bug setup. – Pierre Besson Aug 18 '18 at 21:51
  • The composite profile doesn't change anything. I created this issue https://github.com/jhipster/generator-jhipster/issues/8126 – Anthony Richir Aug 21 '18 at 07:50

1 Answers1

1

spring.cloud.config.server.composite[0].uri property should be mapped to SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_URI environment variable.

See https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-relaxed-binding

Gaël Marziou
  • 16,028
  • 4
  • 38
  • 49