Cloud Build:部署功能-错误:HTTP错误:404,未找到方法

时间:2019-06-23 13:53:10

标签: firebase google-cloud-functions google-cloud-build

我想使用CI / CD管道(Cloud Build)部署我的Cloud Functions。

一切都很好,但是我在这个阶段陷入困境:

Error: HTTP Error: 404, Method not found.
  

注意:PROJECT_ID是我真正的gcloud项目ID。

Starting Step #3 - "deploy function"
Step #3 - "deploy function": Already have image: gcr.io/PROJECT_ID/firebase
Step #3 - "deploy function": ⚠  functions: package.json indicates an outdated version of firebase-functions.
Step #3 - "deploy function":  Please upgrade using npm install --save firebase-functions@latest in your functions directory.
Step #3 - "deploy function": 
Step #3 - "deploy function": === Deploying to 'PROJECT_ID'...
Step #3 - "deploy function": 
Step #3 - "deploy function": i  deploying functions
Step #3 - "deploy function": Running command: npm --prefix "$RESOURCE_DIR" run lint
Step #3 - "deploy function": 
Step #3 - "deploy function": > functions@ lint /workspace/functions
Step #3 - "deploy function": > tslint --project tsconfig.json
Step #3 - "deploy function": 
Step #3 - "deploy function": no-use-before-declare is deprecated. Since TypeScript 2.9. Please use the built-in compiler checks instead.
Step #3 - "deploy function": Running command: npm --prefix "$RESOURCE_DIR" run build
Step #3 - "deploy function": 
Step #3 - "deploy function": > functions@ build /workspace/functions
Step #3 - "deploy function": > tsc
Step #3 - "deploy function": 
Step #3 - "deploy function": ✔  functions: Finished running predeploy script.
Step #3 - "deploy function": i  functions: ensuring necessary APIs are enabled...
Step #3 - "deploy function": 
Step #3 - "deploy function": Error: HTTP Error: 404, Method not found.
Finished Step #3 - "deploy function"
ERROR
ERROR: build step 3 "gcr.io/PROJECT_ID/firebase" failed: exit status 1

我使用了这个git repo作为参考:cloud builders community - firebase

我的 cloudbuild.yaml 正在解密Firebase令牌,构建docker映像并运行该过程:

steps:
  # Decrypt env secrets
  - name: gcr.io/cloud-builders/gcloud
    args:
      - kms
      - decrypt
      - --ciphertext-file=.env.enc
      - --plaintext-file=.env
      - --location=global
      - --keyring=cloudbuild-env
      - --key=firebase-token
    id: 'decrypt'
  - name: gcr.io/cloud-builders/docker
    args: ['build', '-t', 'gcr.io/$PROJECT_ID/firebase', '.']
    id: 'build docker image'
  - name: gcr.io/cloud-builders/npm
    args: ['install']
    dir: functions
    id: 'functions npm install'
  - name: gcr.io/$PROJECT_ID/firebase
    args: ['deploy']
    id: 'deploy functions'
images:
  - gcr.io/$PROJECT_ID/firebase
timeout: 600s

现在我的Dockerfile和firebase.bash与git repo中显示的相同:

Dockerfile

FROM node:8

RUN npm i -g firebase-tools

ADD firebase.bash /usr/bin

RUN chmod +x /usr/bin/firebase.bash

ENTRYPOINT [ "/usr/bin/firebase.bash" ]

firebase.bash

#!/bin/bash

# run the original firebase
if [ $FIREBASE_TOKEN ]; then
  firebase "$@" --token $FIREBASE_TOKEN
else
  firebase "$@"
fi

我还有一个 package.json 来运行部署(对此不确定):

{
  "scripts": {
    "deploy": "firebase deploy --only functions --token \"$FIREBASE_TOKEN\""
  }
}

最后,我的 firebase.json 看起来像这样:

{
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint",
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ],
    "source": "functions"
  }
}

我已经启用了Firebase Adminrôle等,但仍然无法完成这项工作:(

0 个答案:

没有答案