Firebase

Firebase is a platform developed by Google that provides a suite of backend services and tools to help developers easily build, improve, and grow mobile and web applications.

Create Project

Open Firebase and create a new project.

Create Web App connection

  • In the Firebase console, open Firebase Settings

  • Go to your Apps section

  • Select the Web App icon

    • Fill in the App nickname field

    • Check Also set up Firebase Hosting for this app checkbox

    • Press Register app

      Copy firebaseConfig values, as they will be required in the Cloud Build section

    • Press Next

    • Press Next again

    • Copy the Hosting Site ID, as it will be required in [Cloud Build](#cloud-build) section

    • Press Continue to console

Authentication

Firebase makes Authentication easier for Localess.

Localess needs to identify the identity of the users to provide a custom experience and keep the data secure. Please enable Identity Platform in the Settings tab.

Email/Password

Login by Email and Password is enabled by default.

Google Identity Provider

Enable Google as a sign-in method in the Firebase console:

  • In the Firebase console, open the Auth section.

  • On the Sign-in method tab, enable the Google sign-in method

  • Click Save.

In case you limit access only to the organization domain, please fill in the domain name in Cloud Build

Microsoft Identity Provider

To sign in users using Microsoft accounts (Azure Active Directory and personal Microsoft accounts), you must first enable Microsoft as a sign-in provider for your Firebase project:

  • In the Firebase console, open the Auth section.

  • On the Sign-in method tab, enable the Microsoft provider.

  • Add the Client ID and Client Secret from that provider's developer console to the provider configuration:

    • To register a Microsoft OAuth client, follow the instructions in Quickstart: Register an app with the Azure Active Directory v2.0 endpoint. Note that this endpoint supports sign-in using Microsoft personal accounts as well as Azure Active Directory accounts. Learn more about Azure Active Directory v2.0.

    • When registering apps with these providers, be sure to register the *.firebaseapp.com domain for your project as the redirect domain for your app.

  • Click Save.

Hosting

Open the Hosting tab to create a default one.

Firestore

Open the Firestore tab to create a default one.

IAM rights

Add IAM rights to Cloud Builder. Article from the official site here.

The CloudBuild account (@cloudbuild.gserviceaccount.com) should have the next Roles in IAM

  • API Keys Admin

  • Cloud Build Service Account

  • Cloud Functions Developer

  • Firebase Admin

  • Service Account User

Cloud API's to be enabled

  • Cloud Storage for Firebase API (firebasestorage.googleapis.com)

  • Cloud Functions API (cloudfunctions.googleapis.com)

  • Cloud Build API (cloudbuild.googleapis.com)

  • Artifact Registry API (artifactregistry.googleapis.com)

  • Cloud Run API (run.googleapis.com)

  • Eventarc API (eventarc.googleapis.com)

  • PubSub API (pubsub.googleapis.com)

  • Storage API (storage.googleapis.com)

  • Cloud Translation API (translate.googleapis.com)

  • Cloud Billing API (cloudbilling.googleapis.com)

Configuration

The cloudbuild.yaml is already preconfigured in the source code.

Cloud Build

To automatically deploy the latest changes, you will need to create a Cloud Build Trigger :

  • Open Cloud Build Triggers

  • On the Create trigger page, enter the following settings:

    • Enter a name for your trigger.

    • Select the repository event: Push to a branch.

    • Select the repository: https://github.com/Lessify/localess or the forked version

    • Specify the main branch that will start your trigger.

    • Select next for Configuration:

      • Type: Cloud Build configuration file (YAML or JSON)

      • Location: Repository

    • In Advanced you will need to add the next Substitution variables, with their related Firebase values:

      • _LOCALESS_FIREBASE_PROJECT_ID - firebase project id

      • _LOCALESS_FIREBASE_APP_ID - firebase app id

      • _LOCALESS_FIREBASE_STORAGE_BUCKET - firebase storage bucket

      • _LOCALESS_FIREBASE_API_KEY - firebase API Key

      • _LOCALESS_FIREBASE_AUTH_DOMAIN - firebase auth domain

      • _LOCALESS_FIREBASE_MESSAGING_SENDER_ID - firebase messaging sender id

      • _LOCALESS_FIREBASE_MEASUREMENT_ID - firebase measurement id

      • _LOCALESS_AUTH_CUSTOM_DOMAIN - sign in to the custom domain, you can use the organization domain (for example, lessify.io). If not provided it will allow all domains.

      • _LOCALESS_AUTH_PROVIDERS - Auth providers separated by a comma. Available values: GOOGLE and MICROSOFT

  • Click Create to save your build trigger.

Errors that may appear during build or deployment

Cloud Function API not enabled

functions: missing required API cloudfunctions.googleapis.com. Enabling now...

Enable Cloud Functions API in Marketplace.

Check the Cloud APIs to be enabled section.

Artifact Registry API not enabled

artifactregistry: missing required API artifactregistry.googleapis.com. Enabling now...

Enable Artifact Registry API in Marketplace.

Check the Cloud APIs to be enabled section.

Cloud Run API not enabled

functions: missing required API run.googleapis.com. Enabling now...

Enable Cloud Run API in Marketplace.

Check the Cloud APIs to be enabled section.

Eventarc API not enabled

functions: missing required API eventarc.googleapis.com. Enabling now...

Enable Eventarc API in Marketplace.

Check the Cloud APIs to be enabled section.

IAM Roles verification

functions: Failed to verify the project has the correct IAM bindings for a successful deployment.
functions: You can either re-run firebase deploy as a project owner or manually run the following set of gcloud commands:
functions: gcloud projects add-iam-policy-binding PROJECT_NAME --member=serviceAccount:service-project_id@gs-project-accounts.iam.gserviceaccount.com --role=roles/pubsub.publisher
functions: gcloud projects add-iam-policy-binding PROJECT_NAME --member=serviceAccount:service-project_id@gcp-sa-pubsub.iam.gserviceaccount.com --role=roles/iam.serviceAccountTokenCreator
functions: gcloud projects add-iam-policy-binding PROJECT_NAME --member=serviceAccount:project_id-compute@developer.gserviceaccount.com --role=roles/run.invoker
functions: gcloud projects add-iam-policy-binding PROJECT_NAME --member=serviceAccount:project_id-compute@developer.gserviceaccount.com --role=roles/eventarc.eventReceiver
Error: We failed to modify the IAM policy for the project. The functions deployment requires specific roles to be granted to service agents, otherwise the deployment will fail.

Follow the provided instructions. You can execute them in the project console.

The function requires manual deletion

Error: The following functions are found in your project but do not exist in your local source code:
importLocaleJson(us-central1)

You can fix it by deleting the function from one of the following places :

  • Google Cloud Platform Console -> Cloud Functions

  • Google Cloud Platform Console -> Cloud Run

  • Firebase Console -> Functions

Errors in the User Interface

Cloud Translation API not enabled

Cloud Translation API has not been used in project {projectId} before or it is disabled

Enable Cloud Translation API in Marketplace.

Check the Cloud APIs to be enabled section.

First start

For the first time, you will need to go to your project URL under the path '/setup' :

  • <firebase-project-id>.web.app/setup

  • <firebase-project-id>.firebaseapp.com/setup

© Copyright 2024 Lessify Rights Reserved. Build with Localess