autodock
所属分类:构建工具
开发工具:GO
文件大小:0KB
下载次数:0
上传日期:2014-07-28 23:35:58
上 传 者:
sh-1993
说明: 基于来自Docker中心的webhook执行操作
(Perform actions based on a webhook from the Docker hub)
文件列表:
Dockerfile (28, 2014-07-28)
LICENSE (11324, 2014-07-28)
main.go (2739, 2014-07-28)
autodock
========
Perform actions based on a webhook from [the Docker Hub](https://hub.docker.com/).
Idea: Make a simple Docker container that accepts a webhook from the Docker hub and triggers an action (like pulling a fresh copy of a Docker image and restarting services).
## Quick run
```
docker run \
--publish 8080:8080 \
-e 'AUTODOCK_WEBAPP=training/webapp:echo yay' \
rgbkrk/autodock
```
Replace `training/webapp` with the name of the container from the Docker hub you want to trigger on and the command you want to run. You're probably in the mood to make it `docker pull` that image for you automatically and restart some services.
You'll also need to set up the webhook on your Docker repo page (located at https://registry.hub.docker/com/u/{username}/{repo}/settings/webhooks):
![](http://i.imgur.com/gUnu6bd.png)
Once it's set up, you can use a test webhook
![](http://i.imgur.com/SkCc3X8.png)
```
core@nbviewer ~ $ docker run --publish 8080:8080 -e 'AUTODOCK_NBCACHE=rgbkrk/nbcache:echo IM IN YOUR LOGS' rgbkrk/autodock
2014/07/28 23:26:56 Docker repository actions:
2014/07/28 23:26:56 rgbkrk/nbcache: [echo IM IN YOUR LOGS]
2014/07/28 23:32:55 Processing rgbkrk/nbcache
2014/07/28 23:32:55 Running [echo IM IN YOUR LOGS]
2014/07/28 23:32:55 IM IN YOUR LOGS
```
## TODO
* Make configuration suck less
* Create default pull option
* Actually figure out how to link it up with the host to do `docker` actions
## Development
Simply clone this repo, start hacking then run:
```
docker build -t autodock .
```
Make sure you run with some set of AUTODOCKs set up:
```
docker run -e 'AUTODOCK_YAY=example/app:echo hi' -p 8080:8080 autodock
```
You can then verify this with your favorite way to hit up a URL:
#### Python, with Requests
```python
>>> import json
>>> requests.post("http://localhost:8080/autodock/v1/",
... data=json.dumps({"repository":{"repo_name":"example/app"}}),
... headers={'Content-type': 'application/json'})
```
#### cURL
```
curl -X POST -H "Content-Type: application/json" \
-d '{"repository":{"repo_name":"something/else"}}' \
127.0.0.1:8080/autodock/v1/
```
### Example Run
```
$ docker build -t autodock .
Sending build context to Docker daemon 102.4 kB
Sending build context to Docker daemon
Step 0 : FROM google/golang-runtime
# Executing 2 build triggers
Step onbuild-0 : ADD . /gopath/src/app/
---> b51b592cfe60
Step onbuild-1 : RUN /bin/go-build
---> Running in 2d9377aecd4c
---> 88a51b3970fb
---> 88a51b3970fb
Removing intermediate container b81a681a3019
Removing intermediate container 2d9377aecd4c
Successfully built 88a51b3970fb
$ docker run -e 'AUTODOCK_YAY=example/app:echo hi' -p 8080:8080 autodock
2014/07/28 14:58:45 Docker repository actions:
2014/07/28 14:58:45 example/app: [echo hi]
2014/07/28 14:58:57 Processing example/app
2014/07/28 14:58:57 Running [echo hi]
2014/07/28 14:58:57 hi
```
近期下载者:
相关文件:
收藏者: