apogiatzis / docker-compose-livereloader

A docker compose pattern to enable automatic container reloading.
77 stars 12 forks source link

Fixes issues #4, #7 target containers & multiple reloaders #13

Closed dreamPathsProjekt closed 2 years ago

dreamPathsProjekt commented 2 years ago

Changelog

# Example: name of reloaders is reconciler-*, multiple reloaders
docker exec -it reconciler_app-cli bash

>>> import docker
>>> import platform
>>> client = docker.DockerClient(base_url="unix://var/run/docker.sock")

# cannot name it reconciler
>>> client.containers.list(filters={"name": "reloader"})
[]

# multiple reloaders named e.g. reconciler-cli, reconciler-backend, reconciler-frontend
>>> client.containers.list(filters={"name": "reconciler"})
[<Container: bac16483c4>, <Container: 84a2cb39c2>, <Container: fdee64373b>]

# proposed fix, get own container by id
>>> client.containers.get(container_id=platform.node())
<Container: bac16483c4>
# Example: targetting a docker-compose file with app and app-cli services, app-cli-reconciler is the reloader name.

# service named app, returns back 3 results: app, app-cli & the reloader
>>> client.containers.list(filters={"name": "app"})
[<Container: 1d09419b95>, <Container: da4b6fd5ed>, <Container: bac16483c4>]

# exact match does not find grep like name
>>> client.containers.list(filters={"name": "^/app$"})
[]

# we target the docker-compose name now, target specific container
>>> client.containers.list(filters={"name": "^/app_app-cli_1$"})
[<Container: 1d09419b95>]
apogiatzis commented 2 years ago

Hey @dreamPathsProjekt !!

Thanks for your contribution addressing a significant limitation! It's very much appreciated.

The code changes look good to me! Would you mind updating the README as well to reflect the changes?

dreamPathsProjekt commented 2 years ago

Hey @dreamPathsProjekt !!

Thanks for your contribution addressing a significant limitation! It's very much appreciated.

The code changes look good to me! Would you mind updating the README as well to reflect the changes?

Not a problem. You mean examples for how to use multiple reloaders and how to use strict container names in RELOAD_CONTAINER?

apogiatzis commented 2 years ago

Yes :)

dreamPathsProjekt commented 2 years ago

Hey @apogiatzis Sorry to have responded this late. https://github.com/apogiatzis/docker-compose-livereloader/pull/13/commits/5abc46940f2249fb9ddcd957de235db5800ac804 addresses the documentation requests, by adding a more complicated example with reloaders routing and also servers as a good acceptance test, for the fixes proposed.

Note: Images used in all examples, are referencing dreampathsprojekt/livereloader which is the fork https://github.com/dreamPathsProjekt/docker-compose-livereloader version image containing the fixes. This is done, to be able initially to run all examples without issues.

Thanks again and sorry for the wait.

apogiatzis commented 2 years ago

Hey @apogiatzis Sorry to have responded this late. 5abc469 addresses the documentation requests, by adding a more complicated example with reloaders routing and also servers as a good acceptance test, for the fixes proposed.

Note: Images used in all examples, are referencing dreampathsprojekt/livereloader which is the fork https://github.com/dreamPathsProjekt/docker-compose-livereloader version image containing the fixes. This is done, to be able initially to run all examples without issues.

  • To run as PR review, run the scenarios with images as is dreampathsprojekt/livereloader containing the fixes to validate.
  • You can confirm fixes have been applied by changing all docker-compose image repos under test/monitoring to apogiatzis/livereloader to verify faulty behaviour in previous image.
  • After Review comments, I can do a final commit to edit docs and docker-compose files to the finally built image repo apogiatzis/livereloader preparing the PR to be merged. Or you can merge the PR and apply the changes afterwards, in a small PR yourself.

Thanks again and sorry for the wait.

This is great!!! Thank you very much for your contribution and response!

It looks and works great. Merging now.