Docker Community Forums

Share and learn in the Docker community.

Husky pre-commit hooks don't work with Docker

I have a Node JS project that I need to run husky hook on pre-commit. This will run:

docker-compose up
newMan test: Test all endpoints api via a mongodb

The problem is docker won’t run in husky. Please help me. Thank you very much

I have tried:

husky": {
“hooks”: {
“pre-commit”: “cd mongodb && docker run --rm -v “$PWD”:/usr/src/app -w /usr/src/app node:alpine && docker-compose up && npm run test-endpoints && docker-compose down”

The problem is docker-compose up will not close through out the endpoints testing until the end. Husky execute tasks synchronously thus npm run test-endpoints will never run

Does any one know how to get around this? Thank you very much