• Stars
    star
    258
  • Rank 152,884 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created about 9 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Automatic Docker Deployment via Webhooks

docker-hook

Automatic Docker Deployment via Webhooks

docker-hook listens to incoming HTTP requests and triggers your specified command.

Features

  • No dependencies
  • Super lightweight
  • Dead simple setup process
  • Authentification support

Setup

1. Prepare Your Server

Download docker-hook

No worries - it just downloads a Python script. There won't be anything installed or written elsewhere.

$ curl https://raw.githubusercontent.com/schickling/docker-hook/master/docker-hook > /usr/local/bin/docker-hook; chmod +x /usr/local/bin/docker-hook

Start docker-hook

$ docker-hook -t <auth-token> -c <command>
Auth-Token

Please 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.

Command

The command can be any bash command of your choice. See the following example. This command will be triggered each time someone makes a HTTP request.

2. Configuration On Docker Hub

Add 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.

Example

This example will stop the current running yourname/app container, pull the newest version and start a new container.

$ docker-hook -t my-super-safe-token -c sh ./deploy.sh

If you want to store the authentication token as an environment variable, then run

# Make sure there is no space before or after the `=` sign
$ export DOCKER_AUTH_TOKEN=<my-super-safe-token>
$ docker-hook -c sh ./deploy.sh

deploy.sh

#! /bin/bash

IMAGE="yourname/app"
docker ps | grep $IMAGE | awk '{print $1}' | xargs docker stop
docker pull $IMAGE
docker run -d $IMAGE

You 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.

$ curl -X POST yourdomain.com:8555/my-super-safe-token

How it works

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 if the authentification was successful.

Caveat

This 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.

License

MIT License

More Repositories

1

chromeless

🖥 Chrome automation made simple. Runs locally or headless on AWS Lambda.
TypeScript
13,235
star
2

dockerfiles

Collection of lightweight and ready-to-use docker images
Shell
826
star
3

gulp-webserver

Streaming gulp plugin to run a local webserver with LiveReload
JavaScript
356
star
4

laravel-backup

Backup and restore database support for Laravel 4 applications
PHP
351
star
5

git-s3

Easy way to deploy your git repo to an AWS S3 bucket
PHP
228
star
6

Device.swift

Super-lightweight library to detect used device
Swift
220
star
7

timemachine

Test your time-dependent app by monkey patching the Date function and overriding your system time.
JavaScript
131
star
8

calculate-size

Calculate the pixel size (width/height) of a string (with integrated caching)
TypeScript
122
star
9

beanstalkd-cli

Simple to use commandline tool for Beanstalkd
Rust
69
star
10

dotfiles

Contents of my ~/.config
Nix
61
star
11

rust-beanstalkd

Easy-to-use beanstalkd client for Rust (IronMQ compatible)
Rust
46
star
12

awesome-local-first

A collection of awesome local-first projects including offline-first and collaboration functionality
44
star
13

vim-bufonly

Delete all the buffers except the current buffer.
Vim Script
40
star
14

laravel-cash

Simple to use cache layer for your laravel application using memcached & nginx.
PHP
34
star
15

three-vr

Device controls and render steps for mobile virtual reality applications
JavaScript
30
star
16

laravel-queue-checker

Command to check the queue health status
PHP
26
star
17

Icomoon.swift

Use your Icomoon fonts with Swift - auto-generates type safe enums for each icon
Swift
26
star
18

gulp-webserver-article

Code examples for "Gulp as a (development) webserver"
JavaScript
17
star
19

colorrado

Beautiful color gradients based on images
TypeScript
14
star
20

fps-meter

TypeScript
12
star
21

rust-examples

Rust examples in order to learn the language
Rust
11
star
22

zipcoder

Get zipcode, city and country for given coordinates or user location
JavaScript
11
star
23

jquery-rotate

Very lightweight jquery rotate plugin using CSS 3 Transformation
JavaScript
11
star
24

opentelemetry

9
star
25

immersive

Virtual room tour using Google Cardboard
JavaScript
8
star
26

algorithms

Implementation of several algorithms in Javascript
JavaScript
8
star
27

coroni

🦠
TypeScript
8
star
28

figma-plugin-code-syntax-highlighting

TypeScript
8
star
29

laravel-validators

A set of additional validator rules for Laravel 4
PHP
7
star
30

crawl-notifier

Crawl any website and get notified via mail when changes occur
JavaScript
5
star
31

graphql-summit-demo

TypeScript
4
star
32

react-figma-tailwind

JavaScript
4
star
33

dunkelziffer

News crawler for the deep web
JavaScript
4
star
34

challenges

Coding challenges - talk about solutions
Python
3
star
35

graphql-delegate-subscriptions-example

TypeScript
3
star
36

angular-coordinate

Coordiante system for AngularJS
JavaScript
3
star
37

laravel-schema-summary

Creates a summary file of all migrations
2
star
38

es-producthunt

TypeScript
2
star
39

crud-codegen

TypeScript
2
star
40

hackrisk-calm-app

iPhone + Apple Watch App to detect and avoid stressful situations
Swift
2
star
41

base-konfik

Base configuration files for Konfik
TypeScript
2
star
42

contentlayer-blog-2

Jamstack site created with Stackbit
TypeScript
1
star
43

relay-compiler-bug

Minimal reproduction of the recursive input type bug in relay-compiler
JavaScript
1
star
44

codenames

Codenames Game built as React-Native app
JavaScript
1
star
45

slides

Slides for my talks
JavaScript
1
star