Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using "firebase deploy" to deploy to hosting - how does firebase know if it is deploying to hosting and not cloud functions?

I have a firebase project setup and I want to use that same project for both an iOS app and to host a website.

I built a basic iOS app. On my desktop I have a folder:

myiosproject
  - iOS
  - firebase
       - functions
             - index.js

I followed the steps to setup cloud functions which according to the docs are to npm install firebase tools, firebase init and then firebase deploy. I've deployed my code to cloud functions and that works fine.

I've also built a basic website and would like to deploy that to firebase hosting. On my desktop I have a folder:

myWebsite
 - images
 - index.html

According to the hosting docs the process to set up and deploy is the same as for cloud functions: npm install, firebase init, firebase deploy.

So my question is how does firebase "know" if I am running firebase deploy from my website folder in which case the code should go to hosting or whether I am deploying from my firebase functions folder in which case the code should go to firebase cloud functions?

like image 566
Mike Avatar asked Mar 11 '18 09:03

Mike


1 Answers

If you use the Firebase CLI to create your project (https://firebase.google.com/docs/hosting/quickstart) your project will organize your code by default, separating the files to be used for hosting under a "public" directory and the source code for Cloud Functions under a "functions" directory.

Then you can choose to deploy only the hosting

firebase deploy --only hosting

or only the functions:

firebase deploy --only functions

Have a look at the detailed CLI documentation: https://firebase.google.com/docs/cli/

like image 66
Renaud Tarnec Avatar answered Sep 18 '22 19:09

Renaud Tarnec