jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.56k stars 4.02k forks source link

Inconsistent README docker is mandatory to launch the app ! Distributed app with many services can't operate ! #27685

Closed k888888888888888888 closed 2 weeks ago

k888888888888888888 commented 2 weeks ago
Inconsistencies and errors when generating microservices

I'm not very happy with recent updates of JHipster since 2 years ago I could generate my project using microservice JDL without any issues and now are getting a lot of errors and problems, I think the project is not going the correct direction releasing issues like this.

With development profile I can see that Jhipster forces me to use Docker for the database, WHY ?

application.yml

docker: compose: enabled: true lifecycle-management: start-only file: src/main/docker/postgresql.yml

I understand some people are big fan or docker but you should not force it to run the application for development, and let user decide if use or not for deploy, start, etc... why you put enabled by default ?

Is inconsistent ! in the readme file you find this:

Using Docker to simplify development (optional)

Is not optional since by default for all profiles dev , prod etc docker will be invoked. so is not optional.

Second if you try to start the containerized version of docker as the README states:

npm run java:docker docker compose -f src/main/docker/app.yml up -d

[+] Running 15/15 ✔ postgresql 14 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿] 0B/0B Pulled 21.4s ✔ a480a496ba95 Pull complete 5.8s ✔ 894a87c2a602 Pull complete 5.8s ✔ 5c683167ebb4 Pull complete 5.9s ✔ a4a2ff601989 Pull complete 6.0s ✔ f9f18b35445d Pull complete 6.2s ✔ 4341d9f4d10b Pull complete 6.3s ✔ d75b4dfa7494 Pull complete 6.3s ✔ 79531d2c07af Pull complete 6.4s ✔ 38d735e5fe5b Pull complete 16.0s ✔ 021a1a38fd6a Pull complete 19.4s ✔ f79edff05c77 Pull complete 19.5s ✔ 09219b44bd7a Pull complete 19.5s ✔ 9b2fb85f538d Pull complete 19.6s ✔ 1a6cb584f284 Pull complete 19.6s [+] Running 4/5 ✔ Network assembly_default C... 0.1s ✔ Container assembly-keycloak-1 Healthy 22.7s ⠿ Container assembly-postgresql-1 Starting 23.0s ✔ Container assembly-jhipster-registry-1 Started 22.3s ✔ Container mygateway-app-1 C... 0.1s

listen tcp 127.0.0.1:5432: bind: address already in use

It tries to launch 2 instances of PostgreSQL since the gateway includes the definition of docker container for PostgreSQL but for each microservice if uses the same database engine you will have another docker container definition.

So 1 gateway and 4 services with MySQL would result in a conflict for port 3306 since there is no docker network defined and all ports are binded to the same in the host OS.

Motivation for or Use Case

By default the README should be source of true, and DOCKER is mandatory.

By default the application should start without major tweaks or configuration, currently, to run the application you might shutdown your current database service if you already have one, and or install docker yes or yes, otherwise you can set docker compose enabled false.

The application will not works in container mode for microservice JDL since gateway + N services will conflict same port for databases of each component.

Reproduce the error
  1. nvm use 20.12.2
  2. jhipster jdl microservice.jdl
  3. cd mygateway
  4. npm run java:docker
  5. docker compose -f src/main/docker/app.yml up -d
  6. Enjoy.
Related issues

https://github.com/jhipster/generator-jhipster/issues/2509

Suggest a Fix

Update README file to say docker is mandatory, and shutdown any database , keykloak or other existing services in your host OS. Make docker compose enabled false by default.

In any case make appropriate docker network and make sure bind different ports to the host OS example: mysql 1 : 3307 , mysql 2: 3308 , etc ...

JHipster Version(s)

v8.7.1

JHipster configuration

Welcome to JHipster v8.7.1

Welcome to the JHipster Information Sub-Generator

/home/********/microservice
└── (empty)
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "baseName": "workspaces",
    "directoryPath": "./",
    "jhipsterVersion": "8.7.1"
  }
}
Environment and Tools

openjdk version "1.8.0_302" OpenJDK Runtime Environment (build 1.8.0_302-b08) OpenJDK 64-Bit Server VM (build 25.302-b08, mixed mode)

git version 2.34.1

node: v20.12.2 npm: 10.5.0

Docker version 24.0.2, build cb74dfc

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

As alternative you can add a JDL wrapped in below structure

JDL definitions
     application {
  config {
    baseName mygateway
    applicationType gateway
    packageName com.assembly
    authenticationType oauth2
    prodDatabaseType postgresql
    clientFramework angularX
    serviceDiscoveryType eureka
    buildTool maven
    cacheProvider no
    skipClient false
    serverPort 8080
  }
  entities *
}

application {
  config {
    baseName myappa
    applicationType microservice
    packageName com.prestage
    authenticationType jwt
    serviceDiscoveryType eureka
    prodDatabaseType postgresql
    buildTool maven
    cacheProvider no
    serverPort 8081
  }
  entities Unit, SetupProcess
}

application {
  config {
    baseName myappb
    applicationType microservice
    packageName com.prestage
    authenticationType jwt
    serviceDiscoveryType eureka
    prodDatabaseType postgresql
    buildTool maven
    cacheProvider no
    serverPort 8082
  }
  entities SmartLock
}

entity MyEntityB {
    name String
    dateCreation Date
    result Boolean
}

enum MyEnum{
    ONE,
    TWO
}

entity MyEntityA {
    name String
    location String
    myenumValue MyEnum
}

entity MyEntityC {
    id UUID
    model String
    finished Boolean
}

relationship OneToOne {
  MyEntityA to MyEntityB
}

service all with serviceImpl 

paginate MyEntityA, MyEntityC with pagination

microservice MyEntityA, MyEntityB with myappa

microservice MyEntityC with myappb

  
Browsers and Operating System

Not relevant.

No thanks!

mraible commented 2 weeks ago

Yes, we should update the README to state that we've enabled Docker Compose by default and show people how to turn it off in their application.yml.

spring:
  ...
  docker:
    compose:
      enabled: false

The reason we enabled Docker Compose by default is 1) Spring Boot makes this easy to do now, and 2) one of the things many users struggle with is they forget to start Docker containers before starting their app.

mraible commented 2 weeks ago

@mshima Which README.md should I update to have Docker Compose information?

mshima commented 2 weeks ago

@mraible see https://github.com/jhipster/generator-jhipster/pull/27691 change it at will.

mshima commented 2 weeks ago

To support multiples development applications in same environment we should drop the external port in docker services file and let port to be random and detected by spring boot. In prod jhipster docker-compose generator should be used.

k888888888888888888 commented 2 weeks ago

To support multiples development applications in same environment we should drop the external port in docker services file and let port to be random and detected by spring boot. In prod jhipster docker-compose generator should be used.

@mraible

Why close the issue ? The readme is updated but I can't still run the application, of so how can I operate ? this should be ready for development not for production by default IMHO.

To start development on my LOCAL computer should I rent a cloud with docker orchestration and do deploys on every change or how do you suggest to operate !?

You're making easy things complicated. Will stop using Jhipster and do not suggest my company to use this tool anymore is really bad I'm sorry to say.