Run Rubocop with Docker. Fast solution

author @no___tea

You need to run rubocop linter on your CI with Docker.

You can create your own Dockerfile and use it on CI.

I use the fast solution sometimes.

Here it is

I’ve found this repo cagedata/docker-rubocop. It provides easy way to run rubocop with another docker container.

Unfortunately, for now it does not support actual versions of Ruby.

My fork kalashnikovisme/docker-rubocop provides all actual Ruby versions. Also I’ve built images for all those versions.

And now you can run rubocop just like this:

docker run --rm --volume "$PWD:/app" kalashnikovisme/docker-rubocop:ruby-3.0.0

Of course you can use another ruby version, just replace it in tagname. You can find the list of supported ruby versions here.

Example of Gitlab CI configuration to run linter:

--

--