Fork of https://github.com/Schlabbi/docker-notify to add multi-images feature. See config.json.example and Readme.md.
  • JavaScript 99%
  • Dockerfile 1%
Find a file
2024-02-12 02:21:43 +01:00
.github Explicitly installing eslint now in Linter Action 2021-11-02 22:08:04 +01:00
cache [ImgBot] Optimize images (#5) 2021-09-10 21:11:49 +08:00
src index.js: display arch in email 2024-02-12 02:21:43 +01:00
.dockerignore Finished implementation 2018-05-15 19:24:59 +02:00
.editorconfig Add editorconfig and eslint 2021-09-19 20:46:12 +08:00
.eslintrc.json Add editorconfig and eslint 2021-09-19 20:46:12 +08:00
.gitignore Added $msg to substitute msg for webHooks 2021-10-27 22:07:56 -07:00
config.json.example Allow multiple images to check in the images property 2023-12-05 03:12:19 +01:00
docker-compose.yml Allow multiple images to check in the images property 2023-12-05 03:12:19 +01:00
Dockerfile Fixed Dockerfile 2018-08-24 14:25:36 +02:00
LICENSE Added License 2018-05-16 14:55:20 +02:00
package-lock.json Bump axios from 0.21.4 to 0.24.0 (#14) 2021-10-26 21:56:08 +00:00
package.json Added $msg to substitute msg for webHooks 2021-10-27 22:07:56 -07:00
Readme.md Allow multiple images to check in the images property 2023-12-05 03:12:19 +01:00
Synology Readme.md Update Synology Readme.md 2020-10-31 18:06:45 -07:00

Preamble (mid's fork)

This is a fork of Schlabbi/docker-notify, which seems stale, where the configuration file schema has been modified to allow more than one target images (note the s) in the notifyServices objects. You can set the images property to a string containing the image name, like before, or to an array of strings if there are more than one that should share the same hooks.

See the examples below or here.

The source is available on my gitea instance and the docker image is available on dockerhub.

Docker-Notify

Docker-Notify can send you a mail or call a webhook when a Docker image gets updated.

If you are trying to set docker-notify up on a Synology, here is a guide for that.

Environment Variables

  • $CONFIG_DIR defines the directory where the config is stored

Notification Destinations

The following notification destinations are supported:

Type Description
smtpServer email
webHooks Webhook, the $msg variable can be used to insert the docker-notify update message

Setup

  1. Copy the config.json.example file to $CONFIG_DIR/config.json
  2. Fill out the config.json file:
    • Read the self describing schema in src/schema.json
    • If the tag is left out (example: user/repoName), you will receive a mail about any updates made (e.g. nightly builds)
    • If the repository is an official repository, you can leave out the user and just add repoName:tag as image.
  3. Build the Docker container for docker-notify.
  4. Set the variable $CONFIG_DIR in the docker-compose file.
  5. Run the container with docker-compose up -d
  6. If you edit settings in the config, you need to execute docker-compose up again.

Example

Consider the following scenario: You have a server with 2 software services. One is a dockerized webserver and the other one is a dockerized nextcloud image with some customizations, so your docker-compose.yml is looking like this:

version: '3'
services:
  webserver:
    image: apache2
    restart: always
  nextcloud:
    image: customUser/nextcloud:latest
    restart: always

Now you want to be notified if you may update your apache2-server and you want to be notified if you must call your ci-pipeline to rebuild your custom nextcloud-docker-image. So, now your docker-compose.yml file is looking like this:

version: '3'
services:
  webserver:
    image: apache2
    restart: always
  nextcloud:
    image: customUser/nextcloud:latest
    restart: always
  docker-notify:
    image: midmid/docker-notify
    restart: always
    volumes: 
      - /home/someUser/notify/cache:/usr/src/app/cache
      - /home/someUser/notify/config.json:/usr/src/app/config.json

The config.json looks like the following:

{
    "notifyServices":[
        {
            "images": [ "nextcloud:fpm", "gitea/gitea:latest" ],
            "actions": [
                {
                    "type": "mailHook",
                    "instance": "generalMail",
                    "recipient": "info@example.org"
                },
                {
                    "type": "webHook",
                    "instance": "gitlabHook"
                }
            ]
        },
        {
            "images": "httpd",
            "actions": [
                {
                    "type": "mailHook",
                    "instance": "generalMail",
                    "recipient": "info@example.org"
                }
            ]
        }
    ],
    "smtpServer": {
        "generalMail": {
            "host": "mail.example.org",
            "port": 25,
            "username": "docker-notify@example.org",
            "password": "PASSWORD",
            "sendername": "Docker-Notify",
            "senderadress": "docker-notify@example.org"
        }
    },
    "webHooks":{
        "gitlabHook": {
            "reqUrl": "https://ci.example.org",
            "httpMethod": "POST",
            // This one is optional and will default to null.
            "httpBody": {
                "foo": [1, 2, 3]
            }
        },
        "slackHook": {
            "reqUrl": "https://hooks.slack.com/services/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w",
            "httpMethod": "POST",
            "httpHeaders": {"Content-type": "application/json"},
            "httpBody": {
                "text": "$msg"
            }
        }
    }
}