Sync to containers using File Watchers

I think most of us, using docker to run applications simultaneously in one host machine. May be some of you already using docker containers as development aid tool rather than using it’s production capabilities, it’s a bit not ideal when you have to build docker images each time you making a changes to your application sources while it’s running on docker,  It take some effort to rebuild and re-run containers,  Whereas we build images which are ready to deploy or make releases.

This is why i was looking for some syncing tool that sync changes to running docker containers simultaneously. There are lot of other method we could do similar task, but found way to use PHPStrom to do this task using it’s file watchers.

FileWatchers are pretty good feature comes with PHPStrom IDE which can be used for other similar where necessary,

Here’s how i did it..

First of all open up a project, then File -> Settings [Ctrl + Alt + S]

File_Settings

Then it’ll open up Settings window, choose Tools -> File Watchers

Tools_File_Watchers

Next Click on Green add (+) button on right top to add a new file watcher. There are predefined file watcher available to choose from but this instance we’ll choose custom so we can define our own file watcher rules.

choose_custom

 

Now New Watcher Dialog will appear on your screen, this is where we define routines for our own file watcher.

new_watcher

We can fill in watcher name and description fields to identify particular file watcher.

You can define any specific File Type to be watched and Program to be called if any changes been detected to any watching file type. Also you can add extra configurations options depending upon your needs. There are lot of predefined macro’s available to try out!.

Finally!, Select File Watcher and Press Apply and OK.

select_watcher

You’ll notice whenever you change watching file type it’ll automatically sync that file into docker container instantly. If there’s a error it’ll load up failed watcher command in console. so you can identify the problem.

Leave a Reply

Your email address will not be published. Required fields are marked *