代码之家  ›  专栏  ›  技术社区  ›  user3142695

Dockerfile:如何在节点映像上正确安装bcrypt?

  •  1
  • user3142695  · 技术社区  · 7 年前

    node:10.13 形象。应用程序需要 bcrypt . 到目前为止,它对完整节点映像非常有效。但是结果当然太大了,所以我试着用 node:10.13-alpine 形象。因此,我将Dockerfile更改为:

    FROM node:10.13-alpine
    RUN apk --no-cache add --virtual \
          builds-deps \
          build-base \
          python
    
    WORKDIR /home/node/app
    
    COPY ./package*.json ./
    COPY ./.babelrc ./
    
    RUN npm set progress=false \
        && npm config set depth 0 \
        && npm install --only=production --silent \
        && cp -R node_modules prod_node_modules \
        && npm install --silent \
        && apk del builds-deps
    

    但这给了我一些错误。我的Dockerfile缺少什么?当然,我想得到一个小的结果图像。。。

    Step 7/7 : RUN npm set progress=false && npm config set depth 0 && npm install --only=production --silent && cp -R node_modules prod_node_modules && npm install --silent
     ---> Running in 3eadd8526173
    make: Entering directory '/home/node/app/node_modules/bcrypt/build'
      CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
      CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
      CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o
    In file included from ../../nan/nan_new.h:189:0,
                     from ../../nan/nan.h:222,
                     from ../src/bcrypt_node.cc:1:
    ../../nan/nan_implementation_12_inl.h: In static member function 'static Nan::imp::FactoryBase<v8::StringObject>::return_t Nan::imp::Factory<v8::StringObject>::New(v8::Local<v8::String>)':
    ../../nan/nan_implementation_12_inl.h:340:37: warning: 'static v8::Local<v8::Value> v8::StringObject::New(v8::Local<v8::String>)' is deprecated: Use Isolate* version [-Wdeprecated-declarations]
       return v8::StringObject::New(value).As<v8::StringObject>();
                                         ^
    In file included from /root/.node-gyp/10.13.0/include/node/v8.h:26:0,
                     from /root/.node-gyp/10.13.0/include/node/node.h:63,
                     from ../../nan/nan.h:52,
                     from ../src/bcrypt_node.cc:1:
    /root/.node-gyp/10.13.0/include/node/v8.h:5053:37: note: declared here
                     static Local<Value> New(Local<String> value));
                                         ^
    /root/.node-gyp/10.13.0/include/node/v8config.h:324:3: note: in definition of macro 'V8_DEPRECATED'
       declarator __attribute__((deprecated(message)))
       ^~~~~~~~~~
    In file included from ../src/bcrypt_node.cc:1:0:
    ../../nan/nan.h: In constructor 'Nan::Utf8String::Utf8String(v8::Local<v8::Value>)':
    ../../nan/nan.h:1066:53: warning: 'v8::Local<v8::String> v8::Value::ToString() const' is deprecated: Use maybe version [-Wdeprecated-declarations]
           v8::Local<v8::String> string = from->ToString();
                                                         ^
    In file included from /root/.node-gyp/10.13.0/include/node/node.h:63:0,
                     from ../../nan/nan.h:52,
                     from ../src/bcrypt_node.cc:1:
    /root/.node-gyp/10.13.0/include/node/v8.h:10040:15: note: declared here
     Local<String> Value::ToString() const {
                   ^~~~~
    In file included from ../src/bcrypt_node.cc:1:0:
    ../../nan/nan.h:1080:74: warning: 'int v8::String::WriteUtf8(char*, int, int*, int) const' is deprecated: Use Isolate* version [-Wdeprecated-declarations]
             length_ = string->WriteUtf8(str_, static_cast<int>(len), 0, flags);
                                                                              ^
    In file included from /root/.node-gyp/10.13.0/include/node/v8.h:26:0,
                     from /root/.node-gyp/10.13.0/include/node/node.h:63,
                     from ../../nan/nan.h:52,
                     from ../src/bcrypt_node.cc:1:
    /root/.node-gyp/10.13.0/include/node/v8.h:2659:21: note: declared here
                     int WriteUtf8(char* buffer, int length = -1,
                         ^
    /root/.node-gyp/10.13.0/include/node/v8config.h:324:3: note: in definition of macro 'V8_DEPRECATED'
       declarator __attribute__((deprecated(message)))
       ^~~~~~~~~~
    ../src/bcrypt_node.cc: In function 'char {anonymous}::ToCharVersion(v8::Local<v8::String>)':
    ../src/bcrypt_node.cc:66:30: warning: 'v8::String::Utf8Value::Utf8Value(v8::Local<v8::Value>)' is deprecated: Use Isolate version [-Wdeprecated-declarations]
       String::Utf8Value value(str);
                                  ^
    In file included from /root/.node-gyp/10.13.0/include/node/v8.h:26:0,
                     from /root/.node-gyp/10.13.0/include/node/node.h:63,
                     from ../../nan/nan.h:52,
                     from ../src/bcrypt_node.cc:1:
    /root/.node-gyp/10.13.0/include/node/v8.h:2892:28: note: declared here
                       explicit Utf8Value(Local<v8::Value> obj));
                                ^
    /root/.node-gyp/10.13.0/include/node/v8config.h:324:3: note: in definition of macro 'V8_DEPRECATED'
       declarator __attribute__((deprecated(message)))
       ^~~~~~~~~~
    ../src/bcrypt_node.cc: In function 'Nan::NAN_METHOD_RETURN_TYPE {anonymous}::GenerateSalt(Nan::NAN_METHOD_ARGS_TYPE)':
    ../src/bcrypt_node.cc:121:60: warning: 'v8::Local<v8::String> v8::Value::ToString() const' is deprecated: Use maybe version [-Wdeprecated-declarations]
         const char minor_ver = ToCharVersion(info[0]->ToString());
                                                                ^
    In file included from /root/.node-gyp/10.13.0/include/node/node.h:63:0,
                     from ../../nan/nan.h:52,
                     from ../src/bcrypt_node.cc:1:
    /root/.node-gyp/10.13.0/include/node/v8.h:10040:15: note: declared here
     Local<String> Value::ToString() const {
                   ^~~~~
    
      // ... repeated above message
    
      SOLINK_MODULE(target) Release/obj.target/bcrypt_lib.node
      COPY Release/bcrypt_lib.node
      COPY /home/node/app/node_modules/bcrypt/lib/binding/bcrypt_lib.node
      TOUCH Release/obj.target/action_after_build.stamp
    make: Leaving directory '/home/node/app/node_modules/bcrypt/build'
    
    1 回复  |  直到 7 年前
        1
  •  3
  •   valiano    7 年前

    bcrypt 在阿尔卑斯山上不提供预打包,所以npm从源代码构建它。

    你看到的是从GCC,C++编译器,特别是5编译警告。 deprecated-declarations

     warning: 'v8::Local<v8::String> v8::Value::ToString() const' is deprecated: Use maybe version [-Wdeprecated-declarations]
    

    这些警告可能是无害的:它们表示用 deprecated 使用函数属性。这更是一个值得关注的问题

    推荐文章