In this tutorial, we will delve into the process of managing different versions of your application on Firebase Hosting and how to rollback to a previous deployment if the need arises.
You will learn:
- How to deploy your app to Firebase Hosting
- How to manage different versions of your app
- How to rollback to a previous deployment
Prerequisites:
- Basic knowledge of Firebase and Firebase Hosting
- A Firebase project setup
Before you can manage different versions of your app, you need to deploy your app to Firebase Hosting. This can be done by using the Firebase CLI and the firebase deploy
command.
Firebase Hosting stores every successful deployment of your site in a version. You can view all the versions of your site in the Firebase console.
If you need to revert your site to a previous version, Firebase Hosting allows you to rollback to any previous deployment.
Here is an example of deploying your app using the Firebase CLI:
# Navigate to your project directory
cd my_project
# Deploy your app
firebase deploy
In this example, the cd
command is used to navigate to your project directory. The firebase deploy
command then deploys your app to Firebase Hosting.
Here is an example of rolling back a deployment:
# Rollback to a previous deployment
firebase hosting:clone myapp.com:previous-version myapp.com:live
In this example, myapp.com:previous-version
is the source version that you want to rollback to and myapp.com:live
is the destination version.
In this tutorial, you've learned how to deploy your app to Firebase Hosting, manage different versions of your app, and rollback to a previous deployment.
Next steps include exploring other features of Firebase Hosting such as custom domains and SSL configuration.
Additional resources:
- Firebase Hosting Documentation: https://firebase.google.com/docs/hosting
- Firebase CLI Reference: https://firebase.google.com/docs/cli
Solutions:
```bash
# Initialize Firebase in your project directory
firebase init
# Create a simple index.html file
echo "
# Deploy your app
firebase deploy
```
```bash
# Make a change to your app
echo "
# Deploy your app
firebase deploy
# Rollback to the previous version
firebase hosting:clone myapp.com:previous-version myapp.com:live
```
In the first exercise, you're initializing Firebase in your project directory, creating a simple "Hello World" app and deploying it. In the second exercise, you're making a change to your app, deploying it, and then rolling back to the previous version.