Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run pre-commit hook in docker container? #156

Open
heatherKoo07 opened this issue Nov 24, 2021 · 0 comments
Open

How to run pre-commit hook in docker container? #156

heatherKoo07 opened this issue Nov 24, 2021 · 0 comments

Comments

@heatherKoo07
Copy link

heatherKoo07 commented Nov 24, 2021

Hi, I want to run pre-commit hook in my docker container as I moved my dev environment to the docker.

By default, pre-commit requires npm install in local environment to run ./node_modules/pre-commit/hook in .git/hooks/pre-commit script.

When I did some research, I found this link https://spectrum.chat/node/general/pre-commit-with-docker~840290ba-1cb6-40e2-a7ad-7566054638b8. I changed the first line of the pre-commit script manually as below and it worked as expected although it's quite slow.

#!/bin/bash
docker-compose run --rm web sh ./node_modules/pre-commit/hook # web is my docker-compose service name
RESULT=$?
[ $RESULT -ne 0 ] && exit 1
exit 0

Is there a way to customize pre-commit script in configuration or something? (rather than manual change)

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant