I want to deploy my Cloud Functions using a CI/CD pipeline (Cloud Build).
Everything is building fine but I'm stuck at this stage:
Error: HTTP Error: 404, Method not found.
Note : PROJECT_ID is my real gcloud project 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
I used this git repo as a reference : cloud builders community - firebase
My cloudbuild.yaml is decrypting the firebase token, building a docker image and running the process:
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
Now my Dockerfile and my firebase.bash are the same as presented in the 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
I also have a package.json to run the deployement (not sure about that):
{
"scripts": {
"deploy": "firebase deploy --only functions --token \"$FIREBASE_TOKEN\""
}
}
Finally my firebase.json looks like this:
{
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
],
"source": "functions"
}
}
I have enabled the Firebase Admin rôle etc. but still not getting this work :(