{"id":15579691,"url":"https://github.com/schickling/docker-hook","last_synced_at":"2025-04-09T23:17:20.941Z","repository":{"id":68293055,"uuid":"31076621","full_name":"schickling/docker-hook","owner":"schickling","description":"Automatic Docker Deployment via Webhooks","archived":false,"fork":false,"pushed_at":"2020-08-16T05:28:45.000Z","size":14,"stargazers_count":257,"open_issues_count":10,"forks_count":50,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-09T23:17:17.853Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/schickling.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-20T17:43:01.000Z","updated_at":"2025-04-02T03:58:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"310f79d5-e726-462f-9114-8ce3b5cb57f2","html_url":"https://github.com/schickling/docker-hook","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schickling%2Fdocker-hook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schickling%2Fdocker-hook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schickling%2Fdocker-hook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schickling%2Fdocker-hook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schickling","download_url":"https://codeload.github.com/schickling/docker-hook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248125593,"owners_count":21051771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T19:20:32.333Z","updated_at":"2025-04-09T23:17:20.921Z","avatar_url":"https://github.com/schickling.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# docker-hook\n\n\u003e Automatic Docker Deployment via [Webhooks](https://docs.docker.com/docker-hub/repos/#webhooks)\n\n`docker-hook` listens to incoming HTTP requests and triggers your specified command.\n\n## Features\n\n* No dependencies\n* Super lightweight\n* Dead **simple setup process**\n* Authentification support\n\n## Setup\n\n### 1. Prepare Your Server\n\n#### Download `docker-hook`\n\nNo worries - it just downloads a Python script. There won't be anything installed or written elsewhere.\n\n```sh\n$ curl https://raw.githubusercontent.com/schickling/docker-hook/master/docker-hook \u003e /usr/local/bin/docker-hook; chmod +x /usr/local/bin/docker-hook\n```\n\n#### Start `docker-hook`\n\n```sh\n$ docker-hook -t \u003cauth-token\u003e -c \u003ccommand\u003e\n```\n\n##### Auth-Token\n\nPlease choose a secure `auth-token` string or generate one with `$ uuidgen`. Keep it safe or otherwise other people might be able to trigger the specified command. You can pass the `auth-token` as a command line argument, or set it as an environment variable.\n\n##### Command\n\nThe `command` can be any bash command of your choice. See the following [example](#example). This command will be triggered each time someone makes a HTTP request.\n\n### 2. Configuration On Docker Hub\n\nAdd a webhook like on the following image. `example.com` can be the domain of your server or its ip address. `docker-hook` listens to port `8555`. Please replace `my-super-safe-token` with your `auth-token`.\n\n![](http://i.imgur.com/B6QyfmC.png)\n\n## Example\n\nThis example will stop the current running `yourname/app` container, pull the newest version and start a new container.\n\n```sh\n$ docker-hook -t my-super-safe-token -c sh ./deploy.sh\n```\n\nIf you want to store the authentication token as an environment variable, then run\n```sh\n# Make sure there is no space before or after the `=` sign\n$ export DOCKER_AUTH_TOKEN=\u003cmy-super-safe-token\u003e\n$ docker-hook -c sh ./deploy.sh\n```\n#### `deploy.sh`\n\n```sh\n#! /bin/bash\n\nIMAGE=\"yourname/app\"\ndocker ps | grep $IMAGE | awk '{print $1}' | xargs docker stop\ndocker pull $IMAGE\ndocker run -d $IMAGE\n```\n\nYou can now test it by pushing something to `yourname/app` or by running the following command where `yourdomain.com` is either a domain pointing to your server or just its ip address.\n\n```sh\n$ curl -X POST yourdomain.com:8555/my-super-safe-token\n```\n\n## How it works\n\n`docker-hook` is written in plain Python and does have **no further dependencies**. It uses `BaseHTTPRequestHandler` to listen for incoming HTTP requests from Docker Hub and then executes the provided [command](#command) if the [authentification](#auth-token) was successful.\n\n## Caveat\n\nThis tool was built as a proof-of-concept and might not be completly secure. If you have any improvement suggestions please open up an issue.\n\n## License\n\n[MIT License](http://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschickling%2Fdocker-hook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschickling%2Fdocker-hook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschickling%2Fdocker-hook/lists"}