Deploying to Heroku

This step is optional and you can do it if you are interested in deploying this application to Heroku. To continue with this section, you need to have set up a Heroku account and you need to have installed the Heroku Toolbelt.

  1. Once that is done, open a new Command Prompt or Terminal inside the smart-exchange-base folder and run the following command:
$ heroku login

This is your prompt for your Heroku credentials that you have signed up with.

  1. Once you are logged in, let's initialize a new git repository by using the following command:
$ git init
  1. Next, let's get our application ready for deployment. Run the following command:
$ npm run build
or
$ yarn build

This will run the required scripts to build the final dist folder, which will be deployed to Heroku. For everything to run smoothly on Heroku, we have added a file named Procfile that has the config that defines how our application needs to be invoked.

  1. Once the build is completed, run the following command:
$ git add -A
$ git commit -am "Initial Commit"
  1. Now we need to create our Heroku application. This is a one-time set up. Run the following command:
$ heroku create smart-exchange

In the above command your-app-name is the name of your app. I have chosen smart-exchange, you need to choose something different and available. If everything goes well, you should see that a new application has been created successfully and you should also see the Heroku application end point as well as the related git URL.

  1. Now that the application is created, let's link that application to our application. This is also a one-time set up. Run the following command:
$ heroku git:remote -a smart-exchange
  1. Replace smart-exchange in the above command with your app name. This will link our local git to push to Heroku. Let's push the code to Heroku. Run the following command:
$ git push heroku master

If everything goes well, the code will be uploaded to Heroku and you should be able to view the application at https://smart-exchange.herokuapp.com as shown in the following screenshot:

You can run heroku open command to launch the app.

Since the database is pointing to mLab, the application should show the same data that we have seen in our local development environment.

If you were using a local database for development, you need to point your application (update MONGODB_URI) to a public database details otherwise the application will fail to start.

This concludes the set up and deployment of the base application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.31.22