Giter Site home page Giter Site logo

docker-githook's Introduction

Manage git hooks with Docker

This repository explains how to manage git hooks in a dockerized environment. It is interesting to share hooks between team members.

There are three points to configure:

  • the docker/hooks directory: this directory contains the hooks files. These will be the reference hooks files.
-- docker
+-- hooks
|   +-- post-checkout
|   +-- pre-commit
  • the dockerfile.githooks: this dockerfile contains a sequence of commands which will:
    • make the files located in docker/hooks executable
    • clean up all the existing symlinks in the .git/hooks directory of the project
    • create symlinks in this .git/hooks directory to the reference hooks files
FROM busybox:latest

ENTRYPOINT sh -c "cd /tmp/docker/hooks && ls | xargs chmod +x && cd /tmp/.git/hooks && find /tmp/.git/hooks/ -maxdepth 1 -type l -delete && find ../../docker/hooks -type f -exec ln -sf {} /tmp/.git/hooks/ \;"
  • the docker-compose.yml file: this file contains the definition of the container which will be build with the dockerfile.githooks.
  # Git hooks
  githooks-installer:
    build:
      context: .
      dockerfile: './docker/dockerfile.githooks'
    volumes:
      - ./.git:/tmp/.git
      - ./docker/hooks:/tmp/docker/hooks

Run docker-compose up -d to create the symlinks. Now you can test running a git checkout or git commit command. You will see in your terminal respectively post-checkout hook run and pre-commit hook run.

docker-githook's People

Contributors

florencecolas avatar

Watchers

 avatar

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.