I am trying to dockerize my node.js application. I created a Dockerfile, below are the contents of Dockerfile
# Official node base image
FROM node:0.12
# Bundle app source
COPY . /src
RUN apt-get update && apt-get install -y --no-install-recommends libkrb5-dev supervisor \
&& cd /src \
&& npm install \
&& rm -rf /var/lib/apt/lists/*
# copy the supervisor conf file
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Exclude npm cache from the image
VOLUME /root/.npm
# expose environment variable
EXPOSE 3300
# start supervisor
CMD ["/usr/bin/supervisord"]
but while running the npm install command I see following warnings in the logs
> [email protected] install /rate-my-ride-users-api/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos
> (node-gyp rebuild) || (exit 0)
make: Entering directory '/rate-my-ride-users-api/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/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:27:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
#pragma clang diagnostic push
^
../lib/kerberosgss.c:28: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:348: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:687:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
#pragma clang diagnostic pop
I am banging my head on the wall since 12 hours, I almost searched everything on the internet, but I am not able to find out the reason why this is happening. Somewhere I read that I need libkrb5-dev
package so I installed that package also but still the problem continues.
Can anyone explain to me what is happening here ? and how I can resolve this ?
This is just an output from node-gyp. You can ignore this messages if you don't use the MongoDB Enterprise with Kerberos Authentication.
Nevertheless the docker build
command will run successfully and mongoose will also work.
The output above is just about some pragam directives. The pragma statement was introduced with ANSI-C to define compiler options.
For example have a look at:
../lib/kerberosgss.c: In function 'authenticate_gss_client_wrap':
../lib/kerberosgss.c:348:19: warning: variable 'server_conf_flags' set but not used [-Wunused-but-set-variable]
char buf[4096], server_conf_flags;
This just tells you, that the variable server_conf_flags
defined in lib/kerberosgss.c:348:19 is not used anywhere. If you look at the source on github, this is not a problem.
Each C-compiler handles these pragam directives slightly different which is intentionally. Maybe on your local machine you have got a different C-compiler or a completely different OS?
So this is nothing to worry about.
Just like the other answer mentioned, you don't need to worry about these warning. These comes for unknown pragma definition to gcc. For example:
../lib/kerberosgss.c:27:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas] #pragma clang diagnostic push
This warning pops up because of the clang
pragma which in unknown to gcc
.
If you still want to get rid of the warnings, you can set cflags
to ignore these warnings. To do this with node-gyp
, edit ~/.node-gyp/<node_version>/include/node/common.gypi
:
Find the line:
'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ],
and replace it with:
'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', '-Wno-unknown-pragmas','-Wno-unused-but-set-variable', ],
This is where default flags are stored. Note the two extra flags to disable the warnings. In docker, you can use sed
to replace the cflags line with the above.
And I'm not sure why you don't get the warnings in your local environment. Most likely because you are using different compiler other than gcc or may be the gcc version you are using, have those flags already set.
Edit: If you don't see the ~/.node-gyp/
directory, run these commands first. This will install development files for the specified node version:
npm install -g node-gyp
node-gyp install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With