@lemmsoft/docker-windows-detect-changes v1.0.0
Docker Windows Detect Changes
A small tool meant to help with file change detection within Linux containers on Docker for Windows. How it works: 1. An API server is started within the Docker container 2. A file watcher is started in the Windows powershell. 3. The file watcher detects changes and sends an HTTP request to the server. 4. The server performs a "touch" on a file set in the config, which propagates the change detection within the container.
Table Of Contents
Getting Started
First, you'll need to install docker-windows-detect-changes both in Windows (outside the Docker container) and inside the Docker container.
npm i @ramster/general-tools
{
"port": 1234,
"paths": [
{
"fileToTouch": "./back-end/main.js",
"ignoredRegexString": "./back-end/main.js",
"pathToWatch": "./back-end"
}
]
}
The above configuration will start a change detection API server at port 1234, and will set up the change detection watcher to touch the file "./back-end/main.js" whenever something in the "./back-end" directory and its subdirectories is added/changed/deleted. Then, in the docker container, go to the directory containing the file you just created and start the change detection API server by running
docker-windows-detect-changes -s
This will start the server at port 1234. After the server is started, outside the container - in Windows - navigate to the directory containging the .json config file and run
docker-windows-detect-changes
This will start the file watcher for the "pathToWatch" directory. That's it - you're good to go!
Config File Reference
// docker-windows-detect-changes.json
{
"port": number, // the port that the server will be started on; required if using the -s flag when running the docker-windows-detect-changes command
// the configuration for the paths that are to be watched; required when running the docker-windows-detect-changes command without the -s flag
"paths": [
{
"fileToTouch": string, // the file that will be touched when a change is detected, which will in turn propagate the changes inside the docker container
"ignoredRegexString": string | RegExp, // a string or regular expression, matching the files or folders to be excluded from the file watcher; must contain the "fileToTouch" file, otherwise an infinite loop will be created
"pathToWatch": string // the path to the file or folder to be watched
}
]
}
Full CLI Reference
Usage: docker-windows-detect-changes options Options: -s starts a ChangeDetectionServer at the TCP port provided using the -p argument -p required and only used if -s is provided; specifies the TCP port at which the ChangeDetectionServer should be started -c optional; specifies the config file to use for starting the ChangeDetectionWatcher; if not provided, the script will look for a file named "docker-windows-detect-changes.json" in the process' working directory -h, --help display the help menu
4 years ago