简体   繁体   中英

Multi environment setup for firebase not deploying as expected

So, I'm helping someone out with a project which is developed by someone else, but he left. Well, not too relevant but I'm struggling to get a multi environment setup running. Hopefully someone can push me in the right direction.

In the beginning there was one environment. Only production. But for the changes I want an environment running next to the production env. This will be staging.

I have been searching the web on how to set this up and I got something working. It seems to deploy everything, however the changes are not visible on the staging environment.

This is what I have right now in my readme:

#### Deploy to staging

Build the application: `npm run build`

Make sure you are at the correct environment: `firebase use staging`

And apply the target (??) ; `firebase target:apply hosting staging exp-game-staging`

Now you can deploy with:
Initially, for fresh deploy: `firebase deploy`
And later for consequent deployments: `firebase deploy --only hosting`

This gives met the following output:

=== Deploying to 'exp-game-staging'...

i  deploying hosting
i  hosting[exp-game-staging]: beginning deploy...
i  hosting[exp-game-staging]: found 739 files in dist/exp-game-staging
✔  hosting[exp-game-staging]: file upload complete
i  hosting[exp-game-staging]: finalizing version...
✔  hosting[exp-game-staging]: version finalized
i  hosting[exp-game-staging]: releasing new version...
✔  hosting[exp-game-staging]: release complete

✔  Deploy complete!

Project Console: https://console.firebase.google.com/project/***/overview
Hosting URL: https://***.web.app

For the files this seems to work, but it's still using the production database from the staging environment. Locally tho, this is not the case and when I'm developing locally it's using the staging database as expected.

Does anyone know what I'm missing here?

I understand that you are trying to create two environments one for Production and the other for Staging in your Firebase project, but you are having the issue that the staging stage is using the database from the production environment.

Make sure to refer to the steps mentioned in the documentation when you create the two separate environments. Also, the recommendation is to create separate databases for both the environments.

You can achieve this by taking a backup of the data to a storage bucket, and then restore it from there into the other database.

Also, you may refer to this Firestore backup/export/import info here .

If you're using Firebase RTDB, and not Firestore - this documentation might help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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