github-linguist / linguist

Language Savant. If your repository's language is being reported incorrectly, send us a pull request!
MIT License
12.11k stars 4.19k forks source link

Official Docker image? #4613

Open kachkaev opened 5 years ago

kachkaev commented 5 years ago

Preliminary Steps

Please confirm you have...

Problem Description

I'm using linguist from a Node.js project and have almost zero knowledge in Ruby, Ruby Gem and so on. To me github-linguist is just a CLI command I know how to call.

const { stdout } = await execa("github-linguist", ["--json"], {
  cwd: sourceDir,
});

Installing github-linguist locally on Mac OS is not a big deal, however this becomes quite a challenge if I want to call the same command from CI. We use Azure DevOps, in which hosted agents do not come with Ruby. This means that every time I want to run a JavaScript command that depends on github-linguist I need to start the CI Job with this:

Screenshot 2019-08-19 at 15 54 11

Note that the task called Install linguist takes nearly 10 minutes. This is a simple call of gem install github-linguist.

It would be great if github-linguist was made available as an official docker image that I could invoke instead of obtaining Ruby and calling gem install. The CLI command would look something like:

const { stdout } = await execa("docker", [
  "run",
  "--rm",
  "--volume=${sourceDir}:/src",
  "github-linguist:alpine",
  "--json",
]);

Pulling a docker image and spinning a one-off docker container would take seconds, so a lot of CI time would be saved.

There already exists a third-party docker wrapper for linguist (published at crazymax/linguist), but I believe the official version would be a much better thing to have for the community. Some companies do not allow use of non-official docker images as they are more likely to contain unsafe code. The official image is not only trustworthy, but is also more likely to be constantly maintained.

WDYT of publishing an official image to https://hub.docker.com/_/github-linguist?

URL of the affected repository:

Any

pchaigno commented 5 years ago

We could probably go for a first Ubuntu-based image and improve it (reduce its size) later if necessary. @lildude @Alhadis What do you think?

lildude commented 5 years ago

We could probably go for a first Ubuntu-based image and improve it (reduce its size) later if necessary. @lildude @Alhadis What do you think?

I suspect we can go straight for Alphine or similar as the requirements are pretty small.

My only reservation is around the publishing of a GitHub officially sanctioned and supported docker image on Docker Hub or even GitHub Package Registry (GPR).

This statement from @kachkaev is what raises this concern:

Some companies do not allow use of non-official docker images as they are more likely to contain unsafe code. The official image is not only trustworthy, but is also more likely to be constantly maintained.

This is going to need clearance from GitHub Product and an owner/supporter etc will need to be found as it may have legal implications. At the moment Linguist's "ownership" within GitHub is in flux. Having a community maintained and updated image would work but may put that requirement into question for some companies.

I have no problem starting with adding a Dockerfile though.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had activity in a long time. If this issue is still relevant and should remain open, please reply with a short explanation (e.g. "I have checked the code and this issue is still relevant because ___."). Thank you for your contributions.

kachkaev commented 4 years ago

I have checked the code and this issue is still relevant because an official docker image is still not available

ping @lildude. would you be interested in crafting one?

lildude commented 4 years ago

ping @lildude. would you be interested in crafting one?

I assume you mean Dockerfile. I can, but I won't be able to get to it until about the middle of October at the earliest.

dzaytsev91 commented 4 years ago

@lildude I added Dockerfile based on ruby:alpine, please review https://github.com/github/linguist/pull/4687

arkban commented 4 years ago

I stumbled on someone else making a docker image for this: https://github.com/crazy-max/docker-linguist

I'm using it without complaints, thought others might want find it useful.

lildude commented 4 years ago

@arkban that's the one mentioned in the OP 😉

Reminds me, I still need to finish looking into that.

arkban commented 4 years ago

@arkban that's the one mentioned in the OP 😉

Apologies! Firefox find you've failed me for the 58294th time!

lildude commented 3 years ago

https://github.com/github/linguist/pull/4687 has ben merged. Closing.

kachkaev commented 3 years ago

@lildude glad to see the official Dockerfile! WDYT of publishing the image on Dockerhub (https://hub.docker.com/) for ease of access? Pretty much all dockerized projects share their images this way. Until that's done, using linguist via docker in CI is still challenging – one needs to create a non-official image, publish it somewhere and only then use.

It'd be great if we could keep this issue open till that's sorted.

lildude commented 3 years ago

As I mentioned before, I'm reluctant to publish a formal image and the state of Linguist's internal ownership is still in flux so I'm not likely to get sanctioning any time soon.

I'll re-open the issue for tracking, but don't expect this image any time soon.

abdennour commented 3 years ago

Guys! i can offer centralized image using my software: https://github.com/abdennour/dockerfiles However, i prefer to maintain it here. Our main concern is to get the image as a service.

abdennour commented 3 years ago

enjoy now! http://hub.docker.com/r/abdennour/linguist

kachkaev commented 2 years ago

I managed to find an alternative solution to using a docker image. @Nixinova ported linguist to JavaScript, the source is here: https://github.com/Nixinova/Linguist. The npm package is called linguist-js.

So now we can run npx linguist-js on any machine that has Node.js 🎉

Please note that this is not an official port, i.e. a completely different codebase by an independent author. Project goal is the same though and the results are similar.

How about mentioning the port in README?