Firebase configuration for multiple projects/environments

前端 未结 3 794
有刺的猬
有刺的猬 2020-12-14 01:22

I\'m using Cloud Functions for Firebase with three different projects for development, testing and production purposes. Each project has a service-account.json. When I deplo

3条回答
  •  醉酒成梦
    2020-12-14 01:46

    From what I understand of your question, what you are looking for boils down to a solution to translate the cloud functions you are deploying to the appropriate settings, i.e. production, development, and testing, which I assume means each of these is a unique project, and therefore database, in your Firebase environment.

    If the above is true then the following should help.

    Firebase Cloud Functions, and CLI more generally, is able to deploy to a specific project in your Firebase environment. To do this execute the following command in the terminal while in the cloud functions directory.

        $ firebase use --add
    

    This will allow you to pick your additional project (for instance, development) and assign it an alias (I recommend "development" if it is as such). Then when deploying your functions you can choose which project (and therefore database) to deploy to by using the alias.

        $ firebase use default # sets environment to the default alias
        $ firebase use development # sets environment to the development alias
    

    For more information please see: https://firebase.googleblog.com/2016/07/deploy-to-multiple-environments-with.html

    One thing you may have to do for this to work would be to use the default config settings for Cloud Functions.

        $ admin.initializeApp(functions.config().firebase);
    

提交回复
热议问题