Skip to content

Latest commit

 

History

History
112 lines (77 loc) · 3.46 KB

heroku.md

File metadata and controls

112 lines (77 loc) · 3.46 KB

Hosting and deploying to Heroku

Note: this deployment to Heroku relies on git so your app will need to be committed to a git repository. If you haven't done so yet, run the following commands to initialize and commit your source code to a git repository:

# be at the top-level of your app directory
git init
git add .
git commit -m "Initial version"

Create and login to a Heroku account

  1. Go to heroku.com and click on Sign up
  2. Download and install the Heroku CLI
  3. Login to the Heroku CLI using heroku login

Build and deploy from Git to a Docker container

  1. Login to Heroku Container Registry: heroku container:login

  2. 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 named heroku 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
    
  3. 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 the SHOPIFY_API_SECRET values, as you'll need them in the next steps.

  4. Configure the environment variables HOST, SCOPES, SHOPIFY_API_KEY, and SHOPIFY_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=...
  5. 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"
  6. Push the app to Heroku. This will automatically build the docker image and deploy the app.

    git push heroku main

Update URLs in Partner Dashboard and test your app

  1. 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
    
  2. Test the deployed app by browsing to

    https://my-app-name.herokuapp.com/api/auth?shop=my-dev-shop-name.myshopify.com
    

Deploy a new version of the app

  1. Update code and commit to git. If updates were made on a branch, merge branch with main
  2. 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.