Add a docker-compose hook example

Dear maintainer, it took me a while to figure out I could use an external sh file, instead of trying to cramp everything into a one liner in the docker-compose. Maybe it will help other users too. Thanks for creating and maintaining this image. Best,
This commit is contained in:
Matthieu Talbot 2021-11-22 22:08:11 +01:00 committed by GitHub
parent a8beef4f92
commit 28a60c7fc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -156,3 +156,29 @@ $ traefik-certs-dumper kv boltdb --endpoints /the/path/to/mydb.db
```console
$ traefik-certs-dumper kv zookeeper --endpoints localhost:2181
```
## Hook example
Hook can be a one liner passed as a string, or a file for more complex post-hook scenarios. For the former, create a file hook.sh and mount it, then pass "sh hooksh" as a parameter to --post-hook.
Here is a docker-compose example:
```console
traefik-certs-dumper:
image: ldez/traefik-certs-dumper:v2.7.0
container_name: traefik-certs-dumper
entrypoint: sh -c '
apk add jq
; while ! [ -e /data/acme.json ]
|| ! [ `jq ".[] | .Certificates | length" /data/acme.json` != 0 ]; do
sleep 1
; done
&& ls /data/certs/chat.talbot.audio
&& traefik-certs-dumper file --version v2 --domain-subdir --crt-ext=.pem --key-ext=.pem --watch --source /data/acme.json --dest /data/certs/ --post-hook "sh /traefik-certs-dumper/hook.sh"'
labels:
- "traefik.enable=false"
volumes:
- "./letsencrypt-data:/data"
- "./traefik-certs-dumper-data:/traefik-certs-dumper"
- "./out-data:/out-data"
```