carestra
carestra

Reputation: 75

JHipster v7.1.0 - How to create docker-compose conf with dev profile

I can't find any documentation on how to create a custom docker-compose configuration for multiple applications having dev-profile, as in https://www.jhipster.tech/docker-compose/#docker-compose-subgen#Generating a custom Docker-Compose configuration for multiple applications

My microservice architecture consist of one gateway and one microservice and I create those with a jdl-file. When the docker-compose sub-generator runs, it creates a configuration (docker-compose/docker-compose.yml) with SPRING_PROFILES_ACTIVE=prod,api-docs and database conf for prod.

I have try running './mvnw -ntp -Pdev verify jib:dockerBuild' but nothing is changed in the mygateway/src/main/docker/app.yml nor in docker-compose/docker-compose.yml

Upvotes: 1

Views: 575

Answers (1)

carestra
carestra

Reputation: 75

This is how my gateway folder looks like (only the important files):

/gateway/src/main/docker/
     | central-server-config/localhost-config
       | application.yml
     | app.yml

And this is how I created a working docker-compose with dev-profile:

  1. Rebuild project; mvn clean install
  2. Rebuild docker image with dev profile; ./mvnw -ntp -Pdev verify jib:dockerBuild
  3. Copy the src/main/docker/app.yml to src/main/docker/app-dev.yml
  4. In the file app-dev.yml change the following
  • In services.<my_gateway>.environment

    From

  • SPRING_PROFILES_ACTIVE=prod,api-docs
  • SPRING_R2DBC_URL=r2dbc:postgresql://<your_gateway_name>-postgresql:5432/<database_name>
  • SPRING_LIQUIBASE_URL=jdbc:postgresql://<your_gateway_name>-postgresql:5432/<database_name>

To

  • SPRING_PROFILES_ACTIVE=dev,webapp,api-docs
  • SPRING_R2DBC_URL=r2dbc:h2:file://tmp/h2db/db/<database_name>;DB_CLOSE_DELAY=-1
  • SPRING_LIQUIBASE_URL=jdbc:h2:file://tmp/h2db/db/<database_name>;DB_CLOSE_DELAY=-1

Also I removed the hole part of the postgress-container (its not needed)

FYI: The default db location is relative. In the container the relative path on init is the root folder, where appuser may not create directories. Since I use '/tmp/h2db/db'

  1. In the application.yml I change the following

From

eureka:
  client:
    service-url:
      defaultZone: http://admin:${jhipster.registry.password}@localhost:8761/eureka/

To

eureka:
  client:
    service-url:
      defaultZone: http://admin:${jhipster.registry.password}@jhipster-registry:8761/eureka/

FYI: The configuration is telling configserver clients the wrong eureka url via the overrides section. Remove it or just use the same as in the EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE, I did the last.

Then I can start the gateway with dev-profile without any errors. e.g.

docker-compose -f src/main/docker/app-dev.yml up

I have not test it yet, but it should work creating a docker-compose/docker-compose.yml with dev-profile using the same/similar changes as above.

Upvotes: 1

Related Questions