Version: Next

Heroku

Saleor Deployment

To deploy Saleor to Heroku create a new Heroku app and configure your Saleor's git repository together with Heroku app using:

heroku git:remote -a '<saleor-app name>'
heroku buildpacks:set heroku/nodejs
heroku buildpacks:add heroku/python
heroku addons:create heroku-postgresql:hobby-dev
heroku addons:create heroku-redis:hobby-dev
heroku addons:create sendgrid:starter
heroku config:set ALLOWED_HOSTS='<your hosts here>'
heroku config:set NODE_MODULES_CACHE=false
heroku config:set NPM_CONFIG_PRODUCTION=false
heroku config:set SECRET_KEY='<your secret key here>'

ALLOWED_HOSTS are required to properly setup CORS headers. SECRET_KEY is used by Django to store your secret data, it should have a cryptographically strong amount of entropy in case of production deployments.

In the next step, deploy using

git push heroku master

Heroku will build and deploy Saleor automatically.

note

Heroku’s storage is volatile. This means that all instances of your application have separate disks and lose all changes made to the local disk each time the application is restarted. The best approach is to use cloud storage such as Amazon S3. See Storing Files on Amazon S3 for configuration details.

Populating the database with example data

Before logging in to Saleor Dashboard, you need to create a staff / superuser account. To do that, please run the following command:

heroku run -a '<saleor-app name>' python manage.py createsuperuser

Also, if you want to populate the database with sample data, run the following command:

heroku run -a '<saleor-app name>' python manage.py populatedb --createsuperuser
note

The command heroku run -a '<saleor-app name>' python manage.py populatedb --createsuperuser will fill the database with sample data. It is NOT supposed to be executed in a production environment!

Both commands create an admin account with the email: admin@example.com and password: admin

Storefront and Dashboard Deployment

Deployment of both Saleor Storefront and Dashboard require exactly the same steps. First, create new Heroku apps for both services. Then configure both of them and your Storefront and Dashboard git repository using:

heroku git:remote -a '<Heroku-app name>'
heroku buildpacks:set mars/create-react-app
heroku config:set NODE_MODULES_CACHE=false
heroku config:set NPM_CONFIG_PRODUCTION=false
heroku config:set API_URI='<URL to your Saleor instance>/graphql/'

The next step is just to deploy using

git push heroku master

How to log in to Saleor Dashboard

Once the Saleor Dashbord app has been created on Heroku, you can log in via the URL <dashboard-app name>.herokuapp.com using the admin account.

Updating currency exchange rates

You should run this command periodically. The best way to ensure this is done is by using Heroku’s Scheduler service.

To add it to our application:

heroku addons:create scheduler

Then log into your Heroku account, find the Heroku Scheduler add-on in the active add-on list, and have it run the following command on a daily basis:

python manage.py update_exchange_rates --all