8000 GitHub - FlorenceColas/docker-githook: Manage git hooks in a dockerized environement
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

FlorenceColas/docker-githook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Manage git hooks in a dockerized environement

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0