Deploy to production on Heroku

If you don't know where to deploy your back office application, we recommend to use Heroku and to follow this tutorial.

This tutorial is designed to assist people who want to have a step-by-step guide to deploy the Lumber-generated back office to Heroku.

Before following this tutorial, we recommend to read the section named Deploy to production to create a Forest production environment.

If you don’t have a Heroku account yet, sign up here. Then, create your first Heroku application (1) (2).

After creating your application, simply follow the Heroku guide “Deploy using Heroku Git” to push the lumber-generated back office code to the Heroku application.

Push your code using the following command:

Command line
Output
git push heroku master

Your Heroku application is now successfully deployed. The last step to have a complete running application is to deploy a database remotely. In this case, we recommend adding on your Heroku application the free add-on “Heroku Postgres” (1)(2).

Once installed, your Heroku application will contain an environment variable DATABASE_URL with the credentials of your new created database (1). The “Config Vars” section (2) in the Settings tab is where you will configure the FOREST_ENV_SECRET and FOREST_AUTH_SECRET environment variables later (3).

The FOREST_ENV_SECRET and FOREST_AUTH_SECRET environment variables will be given by Forest after creating a production environment from the interface. See how to get them here.

Your new database has no data yet, so you will need to import your local data to this new one.

To do that, you first need to create a dump of your local database.

PGPASSWORD=secret pg_dump -h localhost -p 5416 -U forest forest_demo --no-owner --no-acl -f database.dump

Then, you need to import it to the Heroku database.

heroku pg:psql DATABASE_URL --app lumber-deploy-to-production < database.dump

At this stage, your Heroku application is entirely running with its own database. 🎉 You can make sure by checking the Heroku logs using the command heroku logs -t -a <name_of_your_app>

Command line
Output
heroku logs -t -a lumber-deploy-to-production

Now your back office server is running on Heroku, you can go back to your Forest interface to finalize your production environment. Check out here how to do it.

The Application URL to be used when deploying your back office server on Heroku is something like: https://<my_heroku_app_name>.herokuapp.com

In this example, that would be https://lumber-deploy-to-production.herokuapp.com