L7R7 / gitlab-ci-build-statuses

Get the statuses of the CI pipelines in a group in Gitlab CI and display them on an HTML page
Apache License 2.0
10 stars 1 forks source link

Don't use network_mode: host in docker-compose #50

Closed TheAnachronism closed 2 years ago

TheAnachronism commented 2 years ago

The docker-compose example uses network_mode: host multiple times and the different applications want to bind to all kinds of ports then. In an environment that already has many containers running this can produce many conflicts. It would be better if it was setup with docker networks and only had to use host ports which are actually required (e.g. the 8282 port binding for the actual app.)

L7R7 commented 2 years ago

@TheAnachronism Thanks for reporting this, really appreciated!

I wasn't aware of that as I was just copy-pasting stuff from various places. I'll have a look at it and will improve the example. Alternatively, if you got some spare time, feel free to create a PR with a suggestion.

TheAnachronism commented 2 years ago

Sadly I have no idea how prometheus or grafana work so I don't know which ports are required and how I test if everything actually works... I guess both have at least their default port exposed

L7R7 commented 2 years ago

Prometheus and Grafana need to have one port exposed to make their UIs accessible. In addition to that, Grafana must be able to access Prometheus via HTTP, and Prometheus needs access to all containers (Prometheus scrapes metrics from the other containers, Grafana then queries Prometheus to provide visualizations to the end user). If I only expose ports like in #52, the containers can't access each other. As far as I understand, it now uses the default bridge as network and that doesn't allow communication between containers. So I would need to use a user defined bridge?

L7R7 commented 2 years ago

Found the issue. In the configs for Prometheus and Grafana, I was using 127.0.0.1 to address the containers. Of course that's not possible anymore. Instead I have to use the container names.

52 looks good to me now. I think that was the solution you have in mind?

The confirmation that it works is that http://localhost:9090/targets shows a lot of green badges saying UP (if the config for the build statuses container is correct) as well as Grafana saying that the Prometheus datasource is accessible

TheAnachronism commented 2 years ago

Yeah this looks quite good, thx for the quick work and response