Does anyone know how to use this properly in a doc...
# ktlint
r
Does anyone know how to use this properly in a docker-compose file to scan an existing project
t
do you want to run ktlint check as one of the steps of docker build steps?
r
I would ideally like to run it as a part of a pre-commit hook
SO, in my ideal would that docker image (with ktlint inside) would boot up on commit and format the code
t
imho booting up docker image just for that is a little overkill. Ktlint CLI provides a command to install git hook: https://github.com/pinterest/ktlint#usage or, if you are using Gradle, "ktlint-gradle" provides a task to install git hook as well: https://github.com/JLLeitschuh/ktlint-gradle#additional-helper-tasks
or if you still want to use docker add following command to pre-commit hook:
Copy code
docker run --rm -ti -w "/command" -v `pwd`:/command kkopper/docker-ktlint ktlint
👍 1
r
I am doing it with gradle right now, but that requires users to actively make a call to the gradle command to activate the hook
I was thinking with docker added to my compose file I might be able to enforce it either on run or build or commit
t
imho hook from 'ktlint-gradle' should be fine - it actually calls ktlint via gradle on staged files
r
Ok! Thanks!