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

3

15

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?

Sultan answered 11/3, 2018 at 9:43 Comment(0)
M
38

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/

Molluscoid answered 11/3, 2018 at 9:53 Comment(2)
thanks @renaud. now it makes sense. when initially setting up firebase i think - but can't recall for certain - it asks what you want to setup and you can check 'firestore', 'storage', etc. I definitely didn't choose hosting. I'll go searching but if you know of any easy way to update that, that'd be cool. Thx.Sultan
@Sultan I think firebase init hosting may work (since you can do firebase init functions after an initial install) but I never tried, so I am not 100% sure! Maybe give a try after a backup.Molluscoid
L
4

According to the docs:

firebase-deploy

it deploys the following:

  1. New releases of your Firebase Hosting sites
  2. New or existing Cloud Functions
  3. Rules for Firebase Realtime Database
  4. Rules for Cloud Storage
  5. Rules for Cloud Firestore
  6. Indexes for Cloud Firestore

if you only want to deploy specific features, you can do the following:

firebase deploy --only hosting <-- for hosting
firebase deploy --only functions <-- for cloud functions
Lippert answered 11/3, 2018 at 9:51 Comment(0)
F
0

Use this command to resolve the error, its work for me :- firebase deploy --only hosting: [hosting name]

Fourpenny answered 18/3, 2024 at 17:9 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Allix

© 2022 - 2025 — McMap. All rights reserved.