Basic utility Docker images for C++ development and CI
cd
into your project and run:
docker run --rm -v $(pwd):/workspace/ -w /workspace/ ggabriel96/clang-format:latest <options> <files>
Where:
<options>
are options to be passed toclang-format
, e.g.--dry-run --verbose -Werror
<files>
are the files to be checked or formatted, e.g.$(find . -name '*.hpp')
Conversely, if you want to get into the container, run:
docker run --rm -it -v $(pwd):/workspace/ -w /workspace/ --entrypoint sh ggabriel96/clang-format:latest
Note the -it
flags and the --entrypoint
option.
Finally, if you want to directly apply the formatting, use the -i
flag of clang-format
and don't forget to use the
-u
/--user
option of docker run
so you don't end up with files owned by root
. E.g.:
docker run --rm -u $(id -u):$(id -g) -v $(pwd):/workspace/ -w /workspace/ ggabriel96/clang-format:latest -i --verbose $(find . -name '*.hpp')