Docker Hub Webhook to Rancher
Receives Webhook calls from Docker Hub and Calls In-Service Upgrades in Rancher
Based on the excellent work of Brian Goff (cpuguy83)
The Docker Way
Build a Docker image from the included Dockerfile:
docker build -t myorg/myproject-dockerhub-listener .
You must supply these environment variables to start the app listening:
||API Key to use when calling the app (supply as request param in Docker Hub config)|
||The URL if your Rancher Server API root (e.g. http://myrancher.example.com:8080/v1/projects/1a2)|
||The API Access Key (create via 'API' in the Rancher console)|
||The API Secret Key|
||The name of the rancher service you'd like to upgrade|
Test locally, thus:
docker run -it -p 8080:8080 \ -e api_key="12345" \ -e rancher_url="http://myrancher.example.com:8080/v1/projects/1a2" \ -e rancher_user_key="1A2B3C4D5E6F1234567A" \ -e rancher_secret_key="fTEb6aGsD65RhNE32g6yTY1F8hCl5rQTz" \ -e rancher_service="myservice" \ -e listen_addr="0.0.0.0:8080" \ myorg/myproject-dockerhub-listener
The Manual Way
Add a config file using
This file should be in INI format and is intended for use with handlers
[apiKeys] key = 1a2b3c4d5e6f [rancher] url = http://myrancher.example.com:8080/v1/projects/1a2 userkey = <Rancher API User Key> secretkey = <Rancher API User Secret> service = <Rancher Service Name>
Register a handler in
You an use "Logger" as a reference to how to set this up.
cd hub-listener go build ./hub-listener --listen=0.0.0.0:80 --config-file=config.ini
You should use SSL.
To do so ad a
tls section to your config file, with a
cert and a
You should also use authentication.
Right now DockerHub doesn't really support this, but you can use an api key as a
To handle this, you need to add an
apikeys section to the config file along
with a list of