Generator-jhipster: Enable docker-compose subgenerator for monolithic apps

Created on 13 Apr 2016  路  5Comments  路  Source: jhipster/generator-jhipster

@cbornet and I talked about this during the meetup. We should support monolithic apps in our docker-compose subgen. It's easy to do because all necessary files are already generated in the app (db yml, app yml and docker image).

I would do this this way:

  1. Remove the if block to prevent removing monolithic apps fro app choices
  2. Add a counter to count the number of gateway/monolithic applications
  3. Use this counter to map each port (first on 8080, second on 8081..)
area

Most helpful comment

@cbornet I have managed to make scaling work for monoliths. And it's awesome !
Just remove the ports lines in the monolith-app service and add:

    load-balancer:
        image: dockercloud/haproxy
        links:
            - monolith-app
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
        ports:
            - 8080:80

It will correctly load-balance between the different instances of monolith-app when doing docker-compose scale monolith-app=2 and it will refresh the load-balancer config automatically.

All 5 comments

If we could do docker-compose scale with clustered monoliths :+1:

@cbornet I see how it can be interesting for things like testing Hazelcast session or database clustering.
The problem is that docker-compose scale only works for services that don't expose their ports and then, there is no easy way to access them (well you can still do a docker inspect container-id and figure out the IP...).

So I would propose that we do 2 cases for monolith.
1) non-clustered, all monolith have only one instance bind on 8080,8081,etc...
2) clustered, without binding port, so we can use docker-compose scale. Then, we set up access to the app through an haproxy or nginx proxy/load-balancer (see for example: vegasbrianc/docker-compose-demo ).

Actually, we have the same problem for gateways as we currently can't scale them automatically.

Seems that docker heard us : https://blog.docker.com/2016/04/docker-engine-1-11-runc/

DNS round robin load balancing: It鈥檚 now possible to load balance between containers with Docker鈥檚 networking. If you give multiple containers the same alias, Docker鈥檚 service discovery will return the addresses of all of the containers for round-robin DNS.

I tried after updating docker to 1.11, it seems to work but we cannot bind a port on the application we want to scale (seems logic).
I scaled a sample-app service, went into another container and did curl sample-app:8080/ip (endpoint I've made to return the IP) and it returned me the ip of the first container, always...

@cbornet I have managed to make scaling work for monoliths. And it's awesome !
Just remove the ports lines in the monolith-app service and add:

    load-balancer:
        image: dockercloud/haproxy
        links:
            - monolith-app
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
        ports:
            - 8080:80

It will correctly load-balance between the different instances of monolith-app when doing docker-compose scale monolith-app=2 and it will refresh the load-balancer config automatically.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RizziCR picture RizziCR  路  3Comments

Steven-Garcia picture Steven-Garcia  路  3Comments

DanielFran picture DanielFran  路  3Comments

pascalgrimaud picture pascalgrimaud  路  4Comments

chegola picture chegola  路  4Comments