Code Monkey home page Code Monkey logo

docker-webhook-deploy's Introduction

Webhook Deploy

Synopsis

An Alpine Linux based image that can clone a Git repository and execute a custom setup script upon receiving webhooks.

In order to keep the image small and as close to the base image as possible, no system-wide package is installed; Git and SSH clients are compiled, statically linked, and placed in their own directories.

Environment Variables

The following environment variables must be set before starting the container

  1. SSH_PRIVATE_KEY: a string containing the private key (in OpenSSH format) to access the Git repository
  2. GIT_REPO_URL: Git repository URL
  3. GIT_REPO_BRANCH: Git branch to checkout before running the setup script

In order to prevent unauthorized clients from triggering the webhook handler, one can set WEBHOOK_AUTH_TOKEN environment variable. The webhook receiver server will only accept URL paths that end in WEBHOOK_AUTH_TOKEN.

How it Works

Webhook receiver server listens on port 8000 and does the following upon receiving webhooks:

  1. Clones the specified Git repository
  2. Checks out the specified branch
  3. Looks for .webhook/setup script within the cloned repository and executes it

Notes

  1. Only SSH protocol is supported for cloning Git repositories
  2. .webhook/setup script must have a shebang line (ex. #!/bin/sh)
  3. Webhook receiver server will clone the repository to a temporary directory and removes it after setup script is finished
  4. Setup script will be executed relative to the repository directory
  5. Nothing should be executed directly from the setup script's working directory
  6. It's up to the setup script to compile/process and copy required files to their correct location before the cloned repository directory gets removed
  7. It's up to the setup script to start and track the state of services within the container
  8. Setup script should not start any blocking foreground processes
  9. It's highly recommended to use nohup to start background processes in setup script

(Take a look at example directory for a working setup)

License

MIT

docker-webhook-deploy's People

Contributors

fardjad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

khalilgharbaoui

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.