简体   繁体   English

使用不同的数据进行生产并开发 firebase 个站点

[英]Use different data for production and develop firebase sites

I have a CI/DC pipeline with google cloud build triggers that deploy my code to different sites depending on which branch I push to.我有一个带有谷歌云构建触发器的 CI/DC 管道,它根据我推送到的分支将我的代码部署到不同的站点。 The develop site is a live test - the final check before I merge to master, which triggers a deploy of master to the production site.开发站点是一个实时测试——在我合并到 master 之前的最后检查,这会触发将 master 部署到生产站点。

Currently, both sites use the same firebase Firestore db, and any document changed on the develop site will also be changed on the production site.目前,两个站点都使用相同的 firebase Firestore 数据库,开发站点上更改的任何文档也将在生产站点上更改。

What I want to avoid is creating another firebase project to push the develop code to with a different database, because that means I need a separate set of credentials and would copy the same functions over to the new project every time I change them.我想避免的是创建另一个 firebase 项目以将开发代码推送到不同的数据库,因为这意味着我需要一组单独的凭据,并且每次更改它们时都会将相同的功能复制到新项目。 That's not maintainable and is a lot of work.这是不可维护的,需要大量工作。

What I would like is some way for the develop site to only have access to part of the firestore database, and the production site to have access to another part.我想要的是开发站点只能访问 firestore 数据库的一部分,而生产站点可以访问另一部分的某种方式。

How do people do this?人们如何做到这一点? Is it even possible?有可能吗? Is there a better way?有没有更好的办法? One alternative I can think of is using authentication and creating separate accounts for testing with different access permissions, but this seems a work-around and not the ideal solution.我能想到的一种替代方法是使用身份验证并创建单独的帐户以使用不同的访问权限进行测试,但这似乎是一种变通方法,而不是理想的解决方案。

What you're trying to do sounds like a lot more hassle than using multiple projects , which is the documented and strongly preferred solution.您尝试做的事情听起来比使用多个项目要麻烦得多,后者是记录在案且强烈推荐的解决方案。 Putting everything in one project is a huge anti-pattern in Firebase and Google Cloud, and it will cause you more problems in the long run, in addition to increasing the risk of catastrophic failure if you manage to misconfigure something in that one project.在 Firebase 和 Google Cloud 中,将所有内容都放在一个项目中是一种巨大的反模式,从长远来看,它会给您带来更多问题,此外,如果您设法在该项目中配置错误,还会增加发生灾难性故障的风险。

It's perfectly maintainable to have multiple projects like this, if you apply some scripting to automate the work.如果您应用一些脚本来自动化工作,那么拥有多个这样的项目是完全可维护的。 This is very common, and I strongly suggest thinking through how this would work for you.这很常见,我强烈建议您仔细考虑一下这对您有何作用。

You CI/CD pipeline could definitely check out your updates from source control and deploy them to whatever other project environments you have set up.您的 CI/CD 管道绝对可以从源代码控制中检查您的更新,并将它们部署到您设置的任何其他项目环境中。 It's very common to manage different credentials and configurations for use in CI/CD.管理用于 CI/CD 的不同凭证和配置是很常见的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM