caronc / apprise-api

A lightweight REST framework that wraps the Apprise Notification Library
https://hub.docker.com/r/caronc/apprise
MIT License
661 stars 60 forks source link

How do I mount configuration for topics properly in persistent way, so it just works? #186

Closed knuurr closed 6 months ago

knuurr commented 6 months ago

I can't mount apprise-api configuration via Docker volume in a way, that is detected on container restart. Here's my current mount configuration

    volumes:
      # Ensure proper timezones
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      # Other required paths - per app
      - type: bind
        source: ./apprise.yml
        target: /config/apprise.yml

Here's content of apprise.yml:

# Reference:
# https://github.com/caronc/apprise/wiki/config_yaml

# if no version is specified then version 1 is presumed. Thus this is a
# completely optional field. It's a good idea to just add this line because it
# will help with future ambiguity (if it ever occurs).
version: 1

# Define your URLs
urls:
  # Betanin app
  - ntfy://ntfy:80/betanin:
    - tag: betanin

  # Qbittorrent
  - ntfy://ntfy:80/qb:
    - tag: torrent

  # Uptime-Kuma
  - ntfy://ntfy:80/uptime-kuma:
    - tag: uptime-kuma

The issue is whenever I need to restart Apprise-api container, I need to manually add this configuration through Web GUI through /cfg/apprise path from my web browser. This way I can have my routes configured, and currently only this way.

When added through web panel, Apprise api creates /config/27 directory and there it creates randomized YAML name with actual config. Here's an example, where I manually mounted my apprise.yml file, besides adding it through web UI (no, mount didn't work, as apprise doesn't pick it up):

root@b680df95216a:/config# tree
.
└── 27
    ├── 7a415748edb692e8bf8c4361e9777d92f2dfad2359bbd8c9fbcd49.yaml
    └── apprise.yml

1 directories, 2 files

Here are other ways I've tried with injecting my config through docker-compose, mainly experimenting with other paths or other names for config:

      - type: bind
        source: ./apprise.yml
        target: /config/apprise.yml
      # mount folder, with config.yml/apprise.yml
      - ./config:/config

Generally I don't think I get it how to mount my config. What am I doing wrong, and what is the proper way? I don't want to add my registered topics config, manually, through web portal on every server restart/container restart.

NOTE: I use version provided by linuxserver, but I assume it's not really related to package maintainer.

Thank You in advance!

caronc commented 6 months ago

You should set the Environment Variable APPRISE_STATEFUL_MODE to simple, and then the config becomes just that... very, very simple :slightly_smiling_face: . You should be able to directly mount your file that way:

caronc commented 6 months ago

Did you get this going? Can i close this ticket?

knuurr commented 6 months ago

Did you get this going? Can i close this ticket?

Hi, yes actually I did. Your advice works well!

Just to be clear also for other who may be looking for solution:

    volumes:
      # - ${DATA}/apprise-api/config:/config
      - type: bind
        source: ./apprise.yml
        target: /config/apprise.yml

And as @caronc pointed out I have appropiate env variable set:

    environment:
      - PUID=${UID}
      - PGID=${GID}
      - TZ=Europe/Warsaw
      # Here down below
      - APPRISE_STATEFUL_MODE=simple 
      - APPRISE_CONFIG_LOCK=no
      - APPRISE_DEFAULT_THEME=dark

And it works just fine! Thanks again for pointing that out.