Sidenote: This assumes that user has firebase and heroku installed and has accounts for both services. And assumes that you have the server and client files.
These instructions will lead you through how to deploy a full stack website with a client deployed on Firebase and a server on Heroku.
- Change into your client directory, where your client app files live.
- Initialize a new project
$ firebase init-
The terminal will prompt "What Firebase CLI features do you want to setup for this folder?" Both database and hosting are pre-selected. Unselect the database option by hitting the space bar, leave hosting option selected, and press enter.
-
Select
[create a new project]and hit enter. -
"What do you want to use as your project directory?"
- (public) will be pre-populated.
- Hit enter. This will create a public folder.
-
"Configure as a single page app (rewrite all urls to /index.html)"?
- No
- In the new public folder, delete the index.html
- Move all previous files into the public folder
- Firebase Initialization is complete! Now go to the Firebase Console and click "Create New Project".
- Once the project has been created, type
firebase use --addin the terminal and select the project name you just created.
- "What do you want to use as an alias for this project?" Type an alias and hit enter.
- Deploy:
$ firebase deploy- Once the site has been deployed, the terminal will list the hosting URL. Copy and paste the URL and check out your first deployed static site!
- Make sure you redeploy to firebase if you make any changes to the client app files.
-
** To avoid merge conflicts with github, move outside of client app git repository and then proceed **
-
Create a server directory
-
Change into the new directory
practice-server
-
Sign up for an account on Heroku.
-
In the command line, install the Heroku CLI tools
$ brew install heroku/brew/heroku
- Authorize your computer to have access to your Heroku account
$ heroku login- Initialize the repo
$ git init- Go to github.com and create a new repo
- Add that repo as a git remote
git remote add origin [url]- git add, commit and push all files
- Create a Heroku Project
$ heroku create- Confirm you have a heroku remote by running:
$ git remote -v- Deploy by pushing to Heroku
$ git push heroku masterRe-deploy:
- git add, commit and push to Github
- Push to Heroku
$ git push heroku masterNow both the front-end and back-end are deployed
- In the original repo:
deploy-doughnuts
- ** change into the
practice-clientfolder ** from your command line - Update the src/main.js file to do a fetch request to the deployed server
- Re-deploy your firebase client