traefik-certificate-extractor
traefik-certificate-extractor copied to clipboard
Improving the image
Hey,
I ran into the issue, that I need letsencrypt like certificates for my mailserver, but traefik does not store them in the right format. I found your image and while it does the extracting job quite well, I needed a bit additional functionality.
So I hacked a little bit on the script myself and added / improved the following things:
- added proper command line arguments #3
-
-c
--certs
Certificate file to watch -
-d
--directory
Output directory
-
- added
--include
and--exclude
to either restrict the extraction to specific domains or ignore specific domains and take the rest (they are mutally exclusive) #2 - added a small delay (2s) between the event and the actual work, because watchdog would trigger 2-4 times in my tests
- changed the arguments so that only a single file is wachted instead of every
*.json
file in the folder. It can be changed through the command line argument-c
or--certs
- added the python docker API to automatically restart any container that needs to be notified about the certificate change (can be toggled by command line argument
-r
--restart_container
). It watches for the following label:com.github.DanielHuisman.traefik-certificate-extractor.restart_domain=<DOMAIN>
. Multiple domains can be seperated by,
- added test
-dry-run
option - split export into normal, letsencrypt style (default) and demoted flat export to a command line option (
--flat
) - included changes in the Readme
I'm by no means an experienced python programmer, so the code might look a bit messy.
Please use everything as you need. For testing purposes I added an own docker image at snowmb/traefik-certificate-extractor with a different label.
Thansk for contributing to this repository! I'm currently on holiday, but I will take a look at this PR in a few days.
@DanielHuisman @SnowMB Are these changes still been considered for upstreaming? I love the ability to be able to specify what domain should cause a container to restart :)