由于未知原因,我在从 CI(即 AWS CodeBuild)部署 Firebase 函数时遇到了困难。
firebase deploy
命令是使用 --token
参数调用的,因此这看起来不像是身份验证问题,事实上,托管文件的部署没有任何问题。
我的一个怀疑是,当我在本地运行它时,它的作用就像一个魅力,明显的区别是说 package . (263 B) for uploading
的部分,因为当我在本地运行它时,它有超过 263 字节的方式(当地人说69.23 MB
)。此外,因为它在本地运行没有任何问题,所以我认为 firebase.json
配置不正确没有任何问题。
有人遇到过类似的问题吗?
$ export DOTENV_RUNTIME=qa1 && cross-env NODE_ENV=production firebase deploy --only hosting,functions --token $FIREBASE_TOKEN
...
i deploying functions, hosting
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔ functions: required API cloudbuild.googleapis.com is enabled
✔ functions: required API cloudfunctions.googleapis.com is enabled
i functions: preparing . directory for uploading...
i functions: packaged . (263 B) for uploading
✔ functions: . folder uploaded successfully
i hosting[project-xyz]: beginning deploy...
i hosting[project-xyz]: found 47 files in public
✔ hosting[project-xyz]: file upload complete
i functions: updating Node.js 12 function nextServer(us-central1)...
⚠ functions[nextServer(us-central1)]: Deployment error.
Build failed: function.js does not exist; Error ID: 7485c5b6
Functions deploy had errors with the following functions:
nextServer
To try redeploying those functions, run:
firebase deploy --only "functions:nextServer"
To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
以下是一些相关配置文件的内容:
firebase.json
{
"hosting": {
"public": "public",
"rewrites": [
{
"source": "**",
"function": "nextServer"
}
]
},
"functions": {
"source": ".",
"ignore": [
".git/**",
".firebase/**",
".firebaserc",
"**/node_modules/**",
"**/public/**",
"**/src/**"
]
}
}
package.json
{
...
"main": "dist/server/index.js",
"engines": {
"node": "12"
},
...
}
这是根目录结构。
$ tree -v -L 1 -a
.
├── .firebase
├── .firebaserc
├── .git
├── .gitignore
├── README.md
├── dist
├── firebase.json
├── node_modules
├── package.json
├── public
├── src
└── yarn.lock
答案 0 :(得分:0)
我翻遍了firebase-tools的源码,发现在使用AWS Code Build的时候,源码是在/codebuild/output/src123456789/src/github.com/...
下下载编译的。如果忽略 **/src/**
,则不会将任何文件作为部署目标,因为路径名包含 src
。这也解释了为什么包装尺寸如此之小。
感谢@nVitius 提出问题。