Google Cloud AppEngine - NPM Dependency - 无效的身份验证凭据



我在GC(谷歌云(存储库中创建了一个Node.js项目(我们称之为AA(,然后创建了另一个项目(BB(并使用AA作为依赖项:

"dependencies": {
  "@slack/client": "^4.9.0",
  "axios": "^0.18.0",
  "big-integer": "^1.6.41",
  "https-proxy-agent": "^2.2.1",
  "moment": "^2.24.0",
  "mongoose-auto-increment": "^5.0.1",
  "mssql": "^4.3.0",
  "xml2js": "^0.4.19",
  "AA": "git+https://source.developers.google.com/p/AA/r/AA",
}

现在,当我尝试将其部署到AppEngine时:

gcloud -q app deploy server/app-prod.yaml --project BB

我收到Invalid authentication credentials.错误:

Step #1: npm ERR! Error while executing:
Step #1: npm ERR! /usr/bin/git ls-remote -h -t https://source.developers.google.com/p/AA/r/AA
Step #1: npm ERR!
Step #1: npm ERR! fatal: remote error:
Step #1: npm ERR!
Step #1: npm ERR!
Step #1: npm ERR! Invalid authentication credentials.
Step #1: npm ERR!
Step #1: npm ERR! Please generate a new identifier:
Step #1: npm ERR!   https://source.developers.google.com/new-password
Step #1: npm ERR!
Step #1: npm ERR!
Step #1: npm ERR!
Step #1: npm ERR! exited with error code: 128
Step #1:
Step #1: npm ERR! A complete log of this run can be found in:
Step #1: npm ERR!     /root/.npm/_logs/2019-03-31T12_25_41_034Z-debug.log
Step #1: error building image: error building stage: waiting for process to exit: exit status 1

似乎在 AppEngine 上运行构建的服务没有 AA 存储库的权限。 但是,我不知道它是哪个用户,或者我需要给他什么权限。我在谷歌云页面中找不到任何答案,也没有支持包。

我希望其他人比我以前做过,可以帮助我。我有AABB,因为AA中使用的代码也将用于其他项目(这是一个实用程序项目(

您可以通过使用自定义运行时并在 Dockerfile 中执行 git 用户初始化脚本来解决此问题。

  1. 将依赖项添加到您的 package.json 中,就像您在问题中所做的那样

    "AA": "git+https://source.developers.google.com/p/AA/r/AA"
    
  2. 通过转到此 URL 并按照身份验证步骤获取初始化脚本。

  3. 将其存储在项目根目录中的文件中。将 app.yaml 中的运行时更改为"自定义"。添加如下所示的 Dockerfile:

    FROM gcr.io/google_appengine/nodejs
    RUN /usr/local/bin/install_node '>=8.0.0'
    COPY . /app/
    #Change to filename of the script stored in step 1 
    RUN /bin/bash /app/auth.bash 
    RUN npm install --unsafe-perm || 
      ((if [ -f npm-debug.log ]; then 
          cat npm-debug.log; 
        fi) && false)
    CMD npm start
    
  4. 运行gcloud app deploy

最新更新