Git Product home page Git Product logo

inotify-base's Introduction

inotify-base

A slim and customisable container image designed for quick and easy script hooks on file changes.

This can be used as a sidecar container in Kubernetes/Docker/container based applications to trigger certain HTTP webhook/other commands upon a change to a mounted file/folder.

Configuration

Variable Description Default
INOTIFY_HOOK_SCRIPT The executable to run on a change, as a path mounted on the filesystem None
INOTIFY_WATCH_EVENTS The types of events to listen for as a comma separated list, for example delete,move. A full list of events is available on the inotifywait manpage All events
INOTIFY_WATCH_DIRECTORY The directory to watch for changes in, all subdirectories are recursively watched. /opt/monitor
INOTIFY_HOOK_DELAY A delay (in seconds) to wait before executing a hook, also acts as a debounce cooldown to prevent multiple events within a timespan No delay

It is recommended to mount your INOTIFY_HOOK_SCRIPT in a location that is not used by any other aspect of the container, for example, mounting to /opt/owl-corp/ and using /opt/owl-corp/hook.sh as your INOTIFY_HOOK_SCRIPT option.

Warning

By default, inotifywait will notify on all file events, this includes things like reading directories and opening files.

It is highly recommended to refer to the above mentioned inotifywait manpage for the full list of events to narrow down to those which only modify a file in the ways you specifically wish to observe.

Usage

A Docker compose file using this image might look like the following:

services:
  notifier:
    image: "ghcr.io/owl-corp/inotify-base:latest"
    volumes:
    - type: bind
      source: ./config
      target: /opt/monitor
    - type: bind
      source: ./scripts
      target: /opt/owl-corp
    environment:
      INOTIFY_HOOK_SCRIPT: /opt/owl-corp/script.sh

This will watch for all configuration changes in the local filesystem config directory and execute the script.sh file in the local scripts directory.

License

MIT License.

inotify-base's People

Contributors

jb3 avatar jchristgit avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

jchristgit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.