Note: this deployment to Heroku relies on
git
so your app will need to be committed to agit
repository. If you haven't done so yet, run the following commands to initialize and commit your source code to agit
repository:
# be at the top-level of your app directory
git init
git add .
git commit -m "Initial version"
- Go to heroku.com and click on Sign up
- Download and install the Heroku CLI
- Login to the Heroku CLI using
heroku login
-
Login to Heroku Container Registry:
heroku container:login
-
Create an app in Heroku using
heroku create -a my-app-name -s container
. This will configure Heroku with a container-based app and create a git remote namedheroku
for deploying the app. It will also return the URL to where the app will run when deployed, in the form of:https://my-app-name.herokuapp.com
-
To create a new app in the Partner Dashboard or to link the app to an existing app, run the following command using your preferred package manager:
Using yarn:
yarn run info --web-env
Using npm:
npm run info --web-env
Using pnpm:
pnpm run info --web-env
Take note of the
SCOPES
,SHOPIFY_API_KEY
and theSHOPIFY_API_SECRET
values, as you'll need them in the next steps. -
Configure the environment variables
HOST
,SCOPES
,SHOPIFY_API_KEY
, andSHOPIFY_API_SECRET
for your app. For example:heroku config:set HOST=https://my-app-name.herokuapp.com heroku config:set SCOPES=write_products heroku config:set SHOPIFY_API_KEY=ReplaceWithKEYFromEnvCommand heroku config:set SHOPIFY_API_SECRET=ReplaceWithSECRETFromEnvCommand
Note that these commands can be combined into a single command:
heroku config:set HOST=... SCOPES=... SHOPIFY_API_KEY=... SHOPIFY_API_SECRET=...
-
At the top-level directory of your app's source code, create a
heroku.yml
file with the following content:build: docker: web: Dockerfile config: SHOPIFY_API_KEY: ReplaceWithKEYFromEnvCommand
Commit the
heroku.yml
file to your git repository:git add heroku.yml git commit -m "Add Heroku manifest"
-
Push the app to Heroku. This will automatically build the
docker
image and deploy the app.git push heroku main
-
Update main and callback URLs in Partner Dashboard to point to new app. The main app URL should point to
https://my-app-name.herokuapp.com
and the callback URL should be
https://my-app-name.herokuapp.com/api/auth/callback
-
Test the deployed app by browsing to
https://my-app-name.herokuapp.com/api/auth?shop=my-dev-shop-name.myshopify.com
- Update code and commit to git. If updates were made on a branch, merge branch with
main
- Push
main
to Heroku:git push heroku main
- this will automatically deploy the new version of your app.
Heroku's dynos should restart automatically after setting the environment variables or pushing a new update from git. If you need to restart the dynos manually, use
heroku ps:restart
.