在 Firebase 托管中部署 nextjs 时出错 - 为 cpu 指定的值无效

问题描述 投票:0回答:2

我在通过 firebase-tools 在 Firebase 托管中部署 nextjs 13 时遇到错误。

错误 -

HTTP Error: 400, Could not create Cloud Run service ssrlyeanabot. spec.template.spec.containers.resources.limits.cpu: Invalid value specified for cpu. For the specified value, maxScale may not exceed 30.\nConsider running your workload in a region with greater capacity, decreasing your requested cpu-per-instance, or requesting an increase in quota for this region if you are seeing sustained usage near this limit, see https://cloud.google.com/run/quotas. Your project may gain access to further scaling by adding billing information to your account."

 Error: Failed to create function ssrlyeanabot in region us-central1

package.json-

{
  "name": "testing",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "eslint": "8.36.0",
    "eslint-config-next": "13.2.4",
    "next": "13.2.4",
    "react": "18.2.0",
    "react-dom": "18.2.0"
  }
}

firebase.json

{
  "hosting": {
    "source": ".",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "frameworksBackend": {
      "region": "us-central1"
    }
  }
}

firebase 工具版本 -

11.25.1

重现此问题的步骤

  1. npx create-next-app@latest
  2. firebase 实验:启用网络框架
  3. firebase 初始化托管
  4. firebase 部署 [完毕] IMP -> 启用计费。

请告诉我,我该怎么办。

firebase next.js firebase-hosting firebase-tools
2个回答
7
投票

将密钥

maxInstances: <some number less 30>
添加到 firebase.json 文件的
frameworksBackend
部分

{
  "hosting": {
    "source": ".",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "frameworksBackend": {
      "region": "us-central1",
      "maxInstances": 2
    }
  }
}

说明:

当 Firebase CLI 尝试创建云函数以支持 Nextjs 框架时,部署失败。

使用

firebase --debug deploy
似乎 CLI 没有传递
maxInstance
参数来创建云函数,从而导致错误。

设置

maxInstances
指定此功能所需的最大实例数(应小于您的项目配额 - 30)

firebase.json的架构


0
投票
正在运行 Firebase 和 NextJs 应用程序入门并遇到此问题。对我来说,我需要在

runConfig

 中设置 
apphosting.yaml

runConfig: minInstances: 2 maxInstances: 2 concurrency: 10 cpu: 2 memoryMiB: 1024
    
© www.soinside.com 2019 - 2024. All rights reserved.