Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/remorses/compose-watcher
Watch volumes and restart services in docker compose
https://github.com/remorses/compose-watcher
devtools docker docker-compose nodejs python typescript watch watcher
Last synced: 2 months ago
JSON representation
Watch volumes and restart services in docker compose
- Host: GitHub
- URL: https://github.com/remorses/compose-watcher
- Owner: remorses
- Created: 2020-03-14T10:16:11.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-19T14:51:52.000Z (almost 5 years ago)
- Last Synced: 2024-05-02T02:10:14.577Z (8 months ago)
- Topics: devtools, docker, docker-compose, nodejs, python, typescript, watch, watcher
- Language: Python
- Homepage:
- Size: 211 KB
- Stars: 25
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# compose-watcher
Cli that restarts you docker compose services when a file inside one of its volumes changes.
Useful for faster developement with containers that expose behaviour based on mounted files.
Example usage
- graphql api restart when schema file changes
- graphql api mocks based on schema file ([like this one](https://github.com/remorses/graphql-easy-mocks))
- Every container that generates code and exposes a server based on a config file
- Nodejs container restarts when the src folder changes, recompiling with tsc
- [Mongoke](https://github.com/remorses/mongoke) restarts when config schema changes## Install
```sh
pip3 install compose-watcher
# then you can watch for changes
compose-watcher -f docker-compose.yml
```## Usage
Use the directories you want to track as service volumes.
Also consider using `init: true` in the compose service definition for faster killing of processes.
To not stop the `docker-compose` commands on other terminals there should be always a running container (this is a strange fact about docker-compose).
```
version: '3'services:
api:
build: .
command: sh -c 'tsc --incremental && node index.js'
volumes:
- ./src:/src```
Then execute `compose-watcher` to watch changes.
```sh
compose-watcher -f docker-compose.yml --timeout 5
```TODO add extension filter
## How it works
After running the `compose-watcher` command all the volumes mounted on every service are tracked for change, when a change happens the service where the volume is mounted is restarted toghether with the services in the `depends_on` filed. Then the other services that have the restarted service as a dependency in `depends_on` are restarted too.