[Firebase] Firebase deploy --only functions 에러

이상협·2023년 12월 21일

파이어베이스

목록 보기
2/3

Firebase deploy 에러

Firebase Functions를 사용해보기 위해 로컬에 firebase init을 통해 functions 프로젝트를 구성하는 것 까지는 성공했다.

하지만 npm run deploy(firebase deploy --only functions)를 실행하면서 에러가 발생했다.

에러내용

Could not create Cloud Run service api. 
spec.template.spec.containers.resources.limits.cpu: Invalid value specified for cpu. 
For the specified value, maxScale may not exceed 10.
Consider 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.

firebase functions는 기본적으로 us-central1에서 동작하는데, 사용하는 인스턴스가 제약이 있기 때문에 발생하는 문제였다.

인스턴스 제약을 주자

const {region} = require("firebase-functions");

const regionDefault = region("us-central1")
    .runWith({
      maxInstances: 1,
      timeoutSeconds: 540,
      memory: "1GB",
    }).https;

exports.helloWorld = regionDefault.onRequest((req, res) => {
  res.send("Hello World");
});

이제 deploy해주면 정상적으로 배포된다.

0개의 댓글