schickling / docker-hook Goto Github PK
View Code? Open in Web Editor NEWAutomatic Docker Deployment via Webhooks
License: MIT License
Automatic Docker Deployment via Webhooks
License: MIT License
It shows 500 error when using Gitlab webhook...
How can we make it compatible?
Hi there, just found out your docker-hook.
While testing I noticed the Hub were waiting for a validation but since my python skills are quite low, I leave an issue here if someone would like to enhance it.
Thanx for the PoC though.
The README says the way to use docker-hook is
docker-hook my-super-safe-token ./deploy.sh
But you need to call it like
docker-hook -t my-super-safe-token -c ./deploy.sh
If you really want to have it without named arguments (but positional arguments), just remove the name (hence removing required=True
and "-t", "--token",
and "-c", "--cmd"
.
But I really like named arguments. It makes stuff much clearer.
Giving the AuthToken as a command-line argument is not very secure, because it's visible in top
, w
and history
. You could make the AuthToken argument optional, and fallback to a hardcoded value inside the scipt. So someone could put their AuthToken in the script, and call the script with
$ docker-hook -c <command>
I can make a PR if you're ok with it
I see exceptions raised by docker-hook for every single action I do with my registry.
Exception happened during processing of request from ('127.0.0.1', 41065)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 655, in __init__
self.handle()
File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
method()
File "/usr/local/bin/docker-hook", line 40, in do_POST
for var, val in json_params['repository'].items())
KeyError: 'repository'
This issue comes from the fact that docker-hook expects the POSTed Json to contain a single event. Digging in the code, it seems that nothing is built to handle "grouped" events ({events: [...]}
)
Docker doc for registry notifications states:
While events may be sent in the same envelope, the set of events within that envelope have no implied relationship. For example, the registry may choose to group unrelated events and send them in the same envelope to reduce the total number of requests.
I am wondering if the script is made to be used with docker registry 2 (private registry) ?
Hello,
When looking at the docs, it seems it's only possible to consume one web hook.
I have several projects on docker hub, that should deploy. The correct solution would be to have docker-hook to listning on different ports for the different projects ?
I'm running docker-hock using this commandline:
docker-hook -t token -c ./mydeplyoscript.sh
When receiving the hook from Docker Hub I get this exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/local/lib/python2.7/SocketServer.py", line 321, in process_request
self.finish_request(request, client_address)
File "/usr/local/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/lib/python2.7/SocketServer.py", line 649, in __init__
self.handle()
File "/usr/local/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/usr/local/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
method()
File "/usr/local/bin/docker-hook", line 32, in do_POST
Popen(args.cmd, env=env).wait()
File "/usr/local/lib/python2.7/subprocess.py", line 709, in __init__
errread, errwrite)
File "/usr/local/lib/python2.7/subprocess.py", line 1326, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
When running ./mydeployscript.sh
standalone, everything works fine.
I think docker-hook command not running in the background, So I've used nohup command to docker hook in the background.
I want to store logs in deploy.log when the script is executed by hook.
I've tried below command but it's not working
nohup docker-hook -t $SECRET_KEY -c sh <myscript.sh> >> /deploy.log > /dev/null 2>&1 &
Also, I've tried to pass -c params in " quotation but still logs are not going to deploy.log
nohup docker-hook -t $SECRET_KEY -c sh "sh <myscript.sh> >> /deploy.log" > /dev/null 2>&1 &
I know this is a bit silly but I just noticed that if lets say my auth token is: testing123
$ curl -I -X POST localhost:8555/testing123
HTTP/1.0 200 OK
Server: BaseHTTP/0.3 Python/2.7.12
Date: Fri, 29 Jul 2016 05:34:57 GMT
$ curl -I -X POST localhost:8555/abctesting12356
HTTP/1.0 200 OK
Server: BaseHTTP/0.3 Python/2.7.12
Date: Fri, 29 Jul 2016 05:35:45 GMT
$ curl -I -X POST localhost:8555/abctesxting12356
HTTP/1.0 401 Not authorized
Server: BaseHTTP/0.3 Python/2.7.12
Date: Fri, 29 Jul 2016 05:35:58 GMT
Second request should not be supposed to work right?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.