Docker-node: alpine image should include git

Created on 28 Mar 2017  路  7Comments  路  Source: nodejs/docker-node

npm has its git repo as a dependency feature (see https://docs.npmjs.com/files/package.json#git-urls-as-dependencies). In order for it to work, of course, the git client must be available.

If you try to do a basic npm install in an alpine-based image, and one of the packages uses that feature, it will fail. Similarly, if anything in your package.json refers to a git URL rather than a semver version, it will fail.

Since git, therefore, is a requirement for basic npm usage, I would suggest it should be included in the alpine image via the Dockerfile.

Simple example (from package.json in /my/local/path):

  "dependencies": {
    "compression": "https://github.com/expressjs/compression#1.6.2"
  }

and then

docker run --rm -v /my/local/path:/usr/src/app -w /usr/src/app node:7.4-alpine npm install

Most helpful comment

I am inclined to agree! I will open a PR and we can continue the discussion there.

All 7 comments

I am inclined to agree! I will open a PR and we can continue the discussion there.

That was quick, @LaurentGoderre! I am going to close this issue in favour of the PR.

Closed in favour of #367

Hi! I see that we did add git but not for all versions of node js. Is it possible to do the update so in future versions, git can be available? thank you!

No, git was not added.

We are not modifying the base image. Debian includes it alpine doesn't. With the introduction of multistage builds, it doesn't make sense for us to add git to alpine.

This doesn't work if your package.json has packages that are to be installed directly from git.

just install it yourself if you need it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bfaulk96 picture bfaulk96  路  4Comments

mtibben picture mtibben  路  3Comments

polys picture polys  路  3Comments

jtcmedia picture jtcmedia  路  5Comments

linux17kartik picture linux17kartik  路  4Comments