docker-library / buildpack-deps

MIT License
450 stars 115 forks source link

NPM MongoDB Kerberos Dependency #37

Closed nVitius closed 8 years ago

nVitius commented 9 years ago

The MongoDB package for NPM depends on libkrb5-dev. I'm using the node:0.12.7 image (based on buildpack-deps:jessie). Would it be possible to have this library added to the list of installed dependencies?

yosifkit commented 9 years ago

a majority of arbitrary gem install / npm install / pip install should be successful without additional header/development packages.

We are hesitant to add more libraries to buildpack-deps, but this for a database connection library. Libraries in buildpack-deps are to be generally useful; would this be useful to python and ruby users too?

Size considerations for reference:

$ docker images buildpack-deps
buildpack-deps      jessie              d553eedcb1a3        12 days ago         606.2 MB

$ docker run -it --rm buildpack-deps:jessie
root@91aec4f47f50:/# apt-get update && apt-get install libkrb5-dev
...
The following NEW packages will be installed:
  libkrb5-dev
0 upgraded, 1 newly installed, 0 to remove and 7 not upgraded.
Need to get 42.0 kB of archives.
After this operation, 91.1 kB of additional disk space will be used.
nVitius commented 9 years ago

MongoDB has the ability to use kerberos for authentication. I would imagine that the ruby and python drivers would also require this library.
http://api.mongodb.org/python/current/installation.html
https://docs.mongodb.org/ecosystem/tutorial/ruby-driver-tutorial/#gssapi-kerberos-mechanism

yosifkit commented 9 years ago

Seems ok to me. What do you think @tianon?

tianon commented 9 years ago

Yeah, seems alright -- a PR to the Dockerfile.template would be awesome! :+1:

franky-continu commented 8 years ago

+1

franky-continu commented 8 years ago

I tried adding the apt-get install -y etc for the libkrb5-dev but my build isn't working.

can I get an example of the docker file ?

yosifkit commented 8 years ago

I think the Dockerfile would be something like:

FROM node:5.1
RUN apt-get update && apt-get install -y libkrb5-dev && rm -rf /var/lib/apt/lists/*
# I assume this would happen because of your package.json:
RUN npm install mongodb kerberos

Running it all manually seemed to work (a few warnings but nothing to worry):

$ docker pull node
Using default tag: latest
latest: Pulling from library/node

Digest: sha256:4f12c7d9829b9457ab8b0a05ba8534c4aba9a1e303203bad88f5431dc853ea05
Status: Image is up to date for node:latest
$ docker run -it --rm node bash
root@3a6221150344:/# apt-get update && apt-get install -y libkrb5-dev
Get:1 http://security.debian.org jessie/updates InRelease [63.1 kB]
Get:2 http://security.debian.org jessie/updates/main amd64 Packages [207 kB]          
Ign http://httpredir.debian.org jessie InRelease                                         
Get:3 http://httpredir.debian.org jessie-updates InRelease [136 kB]       
Get:4 http://httpredir.debian.org jessie Release.gpg [2373 B]        
Get:5 http://httpredir.debian.org jessie-updates/main amd64 Packages [3619 B]
Get:6 http://httpredir.debian.org jessie Release [148 kB] 
Get:7 http://httpredir.debian.org jessie/main amd64 Packages [9035 kB]
Fetched 9596 kB in 3s (2442 kB/s)   
Reading package lists... Done
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  krb5-doc
The following NEW packages will be installed:
  libkrb5-dev
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
Need to get 42.2 kB of archives.
After this operation, 92.2 kB of additional disk space will be used.
Get:1 http://security.debian.org/ jessie/updates/main libkrb5-dev amd64 1.12.1+dfsg-19+deb8u1 [42.2 kB]
Fetched 42.2 kB in 2s (15.1 kB/s)      
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libkrb5-dev.
(Reading database ... 21063 files and directories currently installed.)
Preparing to unpack .../libkrb5-dev_1.12.1+dfsg-19+deb8u1_amd64.deb ...
Unpacking libkrb5-dev (1.12.1+dfsg-19+deb8u1) ...
Setting up libkrb5-dev (1.12.1+dfsg-19+deb8u1) ...
root@3a6221150344:/# npm install mongodb kerberos
npm info it worked if it ends with ok
npm info using npm@3.3.12
npm info using node@v5.1.1
npm info attempt registry request try #1 at 12:24:48 AM
npm http request GET https://registry.npmjs.org/mongodb
npm info attempt registry request try #1 at 12:24:48 AM
npm http request GET https://registry.npmjs.org/kerberos
npm http 200 https://registry.npmjs.org/kerberos
npm http 200 https://registry.npmjs.org/mongodb
npm info retry fetch attempt 1 at 12:24:48 AM
npm info attempt registry request try #1 at 12:24:48 AM
npm http fetch GET https://registry.npmjs.org/kerberos/-/kerberos-0.0.17.tgz
npm info retry fetch attempt 1 at 12:24:48 AM
npm info attempt registry request try #1 at 12:24:48 AM
npm http fetch GET https://registry.npmjs.org/mongodb/-/mongodb-2.0.49.tgz
npm http fetch 200 https://registry.npmjs.org/mongodb/-/mongodb-2.0.49.tgz
npm http fetch 200 https://registry.npmjs.org/kerberos/-/kerberos-0.0.17.tgz
npm info attempt registry request try #1 at 12:24:48 AM
npm http request GET https://registry.npmjs.org/nan
npm http 200 https://registry.npmjs.org/nan
npm info retry fetch attempt 1 at 12:24:49 AM
npm info attempt registry request try #1 at 12:24:49 AM
npm http fetch GET https://registry.npmjs.org/nan/-/nan-2.0.9.tgz
npm http fetch 200 https://registry.npmjs.org/nan/-/nan-2.0.9.tgz
npm info attempt registry request try #1 at 12:24:49 AM
npm http request GET https://registry.npmjs.org/mongodb-core
npm info attempt registry request try #1 at 12:24:49 AM
npm http request GET https://registry.npmjs.org/readable-stream
npm info attempt registry request try #1 at 12:24:49 AM
npm http request GET https://registry.npmjs.org/es6-promise
npm http 200 https://registry.npmjs.org/es6-promise
npm http 200 https://registry.npmjs.org/readable-stream
npm info retry fetch attempt 1 at 12:24:49 AM
npm info attempt registry request try #1 at 12:24:49 AM
npm http fetch GET https://registry.npmjs.org/es6-promise/-/es6-promise-2.1.1.tgz
npm info retry fetch attempt 1 at 12:24:49 AM
npm info attempt registry request try #1 at 12:24:49 AM
npm http fetch GET https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.31.tgz
npm http 200 https://registry.npmjs.org/mongodb-core
npm info retry fetch attempt 1 at 12:24:49 AM
npm info attempt registry request try #1 at 12:24:49 AM
npm http fetch GET https://registry.npmjs.org/mongodb-core/-/mongodb-core-1.2.24.tgz
npm http fetch 200 https://registry.npmjs.org/es6-promise/-/es6-promise-2.1.1.tgz
npm http fetch 200 https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.31.tgz
npm http fetch 200 https://registry.npmjs.org/mongodb-core/-/mongodb-core-1.2.24.tgz
npm info attempt registry request try #1 at 12:24:49 AM
npm http request GET https://registry.npmjs.org/bson
npm http 200 https://registry.npmjs.org/bson
npm info retry fetch attempt 1 at 12:24:49 AM
npm info attempt registry request try #1 at 12:24:49 AM
npm http fetch GET https://registry.npmjs.org/bson/-/bson-0.4.20.tgz
npm http fetch 200 https://registry.npmjs.org/bson/-/bson-0.4.20.tgz
npm info attempt registry request try #1 at 12:24:49 AM
npm http request GET https://registry.npmjs.org/core-util-is
npm info attempt registry request try #1 at 12:24:49 AM
npm http request GET https://registry.npmjs.org/isarray
npm info attempt registry request try #1 at 12:24:49 AM
npm http request GET https://registry.npmjs.org/string_decoder
npm info attempt registry request try #1 at 12:24:49 AM
npm http request GET https://registry.npmjs.org/inherits
npm http 200 https://registry.npmjs.org/string_decoder
npm http 200 https://registry.npmjs.org/inherits
npm http 200 https://registry.npmjs.org/core-util-is
npm info retry fetch attempt 1 at 12:24:49 AM
npm info attempt registry request try #1 at 12:24:49 AM
npm http fetch GET https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz
npm http 200 https://registry.npmjs.org/isarray
npm info retry fetch attempt 1 at 12:24:49 AM
npm info attempt registry request try #1 at 12:24:49 AM
npm http fetch GET https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz
npm info retry fetch attempt 1 at 12:24:49 AM
npm info attempt registry request try #1 at 12:24:49 AM
npm http fetch GET https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz
npm info retry fetch attempt 1 at 12:24:49 AM
npm info attempt registry request try #1 at 12:24:49 AM
npm http fetch GET https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz
npm http fetch 200 https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz
npm http fetch 200 https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz
npm http fetch 200 https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz
npm http fetch 200 https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz
npm info lifecycle bson@0.4.20~preinstall: bson@0.4.20
npm info lifecycle core-util-is@1.0.2~preinstall: core-util-is@1.0.2
npm info lifecycle es6-promise@2.1.1~preinstall: es6-promise@2.1.1
npm info lifecycle inherits@2.0.1~preinstall: inherits@2.0.1
npm info lifecycle isarray@0.0.1~preinstall: isarray@0.0.1
npm info lifecycle mongodb-core@1.2.24~preinstall: mongodb-core@1.2.24
npm info lifecycle nan@2.0.9~preinstall: nan@2.0.9
npm info lifecycle string_decoder@0.10.31~preinstall: string_decoder@0.10.31
npm info lifecycle readable-stream@1.0.31~preinstall: readable-stream@1.0.31
npm info lifecycle kerberos@0.0.17~preinstall: kerberos@0.0.17
npm info lifecycle mongodb@2.0.49~preinstall: mongodb@2.0.49
npm info linkStuff bson@0.4.20
npm info linkStuff core-util-is@1.0.2
npm info linkStuff es6-promise@2.1.1
npm info linkStuff inherits@2.0.1
npm info linkStuff isarray@0.0.1
npm info linkStuff mongodb-core@1.2.24
npm info linkStuff nan@2.0.9
npm info linkStuff string_decoder@0.10.31
npm info linkStuff readable-stream@1.0.31
npm info linkStuff kerberos@0.0.17
npm info linkStuff mongodb@2.0.49
npm info lifecycle bson@0.4.20~install: bson@0.4.20
npm info lifecycle core-util-is@1.0.2~install: core-util-is@1.0.2
npm info lifecycle es6-promise@2.1.1~install: es6-promise@2.1.1
npm info lifecycle inherits@2.0.1~install: inherits@2.0.1
npm info lifecycle isarray@0.0.1~install: isarray@0.0.1
npm info lifecycle mongodb-core@1.2.24~install: mongodb-core@1.2.24
npm info lifecycle nan@2.0.9~install: nan@2.0.9
npm info lifecycle string_decoder@0.10.31~install: string_decoder@0.10.31
npm info lifecycle readable-stream@1.0.31~install: readable-stream@1.0.31
npm info lifecycle kerberos@0.0.17~install: kerberos@0.0.17

> kerberos@0.0.17 install /node_modules/kerberos
> (node-gyp rebuild) || (exit 0)

gyp info it worked if it ends with ok
gyp info using node-gyp@3.0.3
gyp info using node@5.1.1 | linux | x64
gyp http GET https://nodejs.org/download/release/v5.1.1/node-v5.1.1-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v5.1.1/node-v5.1.1-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v5.1.1/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v5.1.1/SHASUMS256.txt
gyp info spawn python2
gyp info spawn args [ '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/node_modules/kerberos/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/root/.node-gyp/5.1.1/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/root/.node-gyp/5.1.1',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir=/node_modules/kerberos',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/node_modules/kerberos/build'
  CXX(target) Release/obj.target/kerberos/lib/kerberos.o
  CXX(target) Release/obj.target/kerberos/lib/worker.o
  CC(target) Release/obj.target/kerberos/lib/kerberosgss.o
../lib/kerberosgss.c:36:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
 #pragma clang diagnostic push
 ^
../lib/kerberosgss.c:37:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
 ^
../lib/kerberosgss.c: In function 'authenticate_gss_client_wrap':
../lib/kerberosgss.c:362:19: warning: variable 'server_conf_flags' set but not used [-Wunused-but-set-variable]
   char buf[4096], server_conf_flags;
                   ^
../lib/kerberosgss.c: At top level:
../lib/kerberosgss.c:930:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
 #pragma clang diagnostic pop
 ^
  CC(target) Release/obj.target/kerberos/lib/base64.o
  CXX(target) Release/obj.target/kerberos/lib/kerberos_context.o
  SOLINK_MODULE(target) Release/obj.target/kerberos.node
  COPY Release/kerberos.node
make: Leaving directory '/node_modules/kerberos/build'
gyp info ok 
npm info lifecycle mongodb@2.0.49~install: mongodb@2.0.49
npm info lifecycle bson@0.4.20~postinstall: bson@0.4.20
npm info lifecycle core-util-is@1.0.2~postinstall: core-util-is@1.0.2
npm info lifecycle es6-promise@2.1.1~postinstall: es6-promise@2.1.1
npm info lifecycle inherits@2.0.1~postinstall: inherits@2.0.1
npm info lifecycle isarray@0.0.1~postinstall: isarray@0.0.1
npm info lifecycle mongodb-core@1.2.24~postinstall: mongodb-core@1.2.24
npm info lifecycle nan@2.0.9~postinstall: nan@2.0.9
npm info lifecycle string_decoder@0.10.31~postinstall: string_decoder@0.10.31
npm info lifecycle readable-stream@1.0.31~postinstall: readable-stream@1.0.31
npm info lifecycle kerberos@0.0.17~postinstall: kerberos@0.0.17
npm info lifecycle mongodb@2.0.49~postinstall: mongodb@2.0.49
/
+-- kerberos@0.0.17 
| `-- nan@2.0.9 
`-- mongodb@2.0.49 
  +-- es6-promise@2.1.1 
  +-- mongodb-core@1.2.24 
  | `-- bson@0.4.20 
  `-- readable-stream@1.0.31 
    +-- core-util-is@1.0.2 
    +-- inherits@2.0.1 
    +-- isarray@0.0.1 
    `-- string_decoder@0.10.31 

npm WARN ENOENT ENOENT: no such file or directory, open '/package.json'
npm WARN EPACKAGEJSON !invalid#1 No description
npm WARN EPACKAGEJSON !invalid#1 No repository field.
npm WARN EPACKAGEJSON !invalid#1 No README data
npm WARN EPACKAGEJSON !invalid#1 No license field.
npm info ok 
root@3a6221150344:/# 

When npm installing mongodb without kerberos it also works but gives a warning that kerberos might be needed.

npm WARN EPEERINVALID mongodb-core@1.2.24 requires a peer of kerberos@~0.0 but none was installed.
franky-continu commented 8 years ago

Mockgoose depends on mongodb-download and it throws an exception

winfinit/mongodb-download#5

mongodb-prebuilt -> mongodb-download and the exception

franky-continu commented 8 years ago
FROM node:5.1
RUN apt-get update && apt-get install -y libkrb5-dev && rm -rf /var/lib/apt/lists/*
# I assume this would happen because of your package.json:
RUN npm install mongodb kerberos

what about all the copy to src/ is that on the node:5.1? can I use latest?

yosifkit commented 8 years ago

latest should be fine, I just like more control over when version bumps happen. Yeah, you'll still need to COPY in your source files like the onbuild image does.

FROM node:5.1
RUN apt-get update && apt-get install -y libkrb5-dev && rm -rf /var/lib/apt/lists/*

# this line is probably not needed, but is how I was testing installing mongodb module without a package.json
RUN npm install mongodb kerberos

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
EXPOSE 8080
CMD [ "npm", "start" ]
franky-continu commented 8 years ago

Awesome, it got fixed on a dependency for Mockgoose (mongodb-prebuilt which depended on mongodb-download which didn’t worked for debian 8.2)

Thanks a bunch Franky Diaz-Trepat Full Stack Engineer +1 (720) 295-0592 / 401-1276 skype: franky.diaz.trepat franky@continu.co

On Dec 7, 2015, at 1:32 PM, yosifkit notifications@github.com wrote:

latest should be fine, I just like more control over when version bumps happen. Yeah, you'll still need to COPY in your source files like the onbuild image does.

FROM node:5.1 RUN apt-get update && apt-get install -y libkrb5-dev && rm -rf /var/lib/apt/lists/*

this line is probably not needed, but is how I was testing installing mongodb module without a package.json

RUN npm install mongodb kerberos

RUN mkdir -p /usr/src/app WORKDIR /usr/src/app

COPY package.json /usr/src/app/ RUN npm install COPY . /usr/src/app EXPOSE 8080 CMD [ "npm", "start" ] — Reply to this email directly or view it on GitHub https://github.com/docker-library/buildpack-deps/issues/37#issuecomment-162652553.

mgcrea commented 8 years ago

:+1: