Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Latest commit

 

History

History
132 lines (78 loc) · 3.8 KB

FIREBASE-DEV-TUTORIAL.md

File metadata and controls

132 lines (78 loc) · 3.8 KB

Firebase developement tutorial

We're using firebase as part of our backend to accelerate the process of making prototype of our app (serverless):

  • User authentification managed by Firebae auth.

  • Data stored in database is managed by Firestore.

  • Photos uploaded in our app is managed by Firebase storage.

  • Scheldued tasks are managed by Firebase cloud functions.

To use Firebase in your proect your need to create a Firebase project using Firebase console. and install Firebase tools (CLI)

Requirement

A minimium of knowledge is required of the following frameworks and technologies:

  • Node.js

  • Firebase SDK

  • Firestore

  • Firebase Storage

  • Firebase Cloud Functions

1. Install Firebase CLI (tools)

First you need to install Firebase tools using a method that matches your operating system by following Firebase CLI documentation.

I'm using Ubuntu 20.04 for developement, so I'm running this command:

curl -sL firebase.tools | upgrade=true bash

2. Initialize Firebase project

After installing the CLI, you must authenticate.

  1. Log into Firebase using you Google account:
firebase login
  1. Link your Firebase project and initialize it inside backend folder:
firebase init

The firebase init command steps you through setting up your project directory and some Firebase products.

At the end of initialization, Firebase automatically creates the following two files at the root of your local app directory:

  • A firebase.json configuration file that lists your project configuration.

  • A .firebaserc file that stores your project aliases.

3. Setup Firebase Local Emulator

For your developement & test, It would be better to run it locally rather using production envirement to test your work.

Firebase provide a local emulator for almost all their services to test aigaint them locally: Firebase Local Emulator Suite

Emulator suite is part Firebase CLI, so all you need now is to run this command:

firebase init emulators

For more information about ho to install and configure emulators, check "Install, configure and integrate"

After setting up the emulators, run this command to start them:

firebase emulators:start

4. Deployment

The Firebase CLI manages deployment of code and assets to your Firebase project, including:

Command list we need for our project are the following:

  • Cloud Storage for Firebase rules
firebase deploy --only storage
  • Cloud Firestore rules and indexes
firebase deploy --only firestore
  • Cloud Firestore rules
firebase deploy --only firestore:rules
  • Cloud Firestore indexes
firebase deploy --only firestore:indexes
  • Cloud Functions for Firebase
firebase deploy --only functions

You may combine all these commands into one command:

firebase deploy --only functions,firestore,storage