Skip to content

Instantly share code, notes, and snippets.

@gelilaa
Last active May 12, 2022 15:29
Show Gist options
  • Save gelilaa/726551e1d3b71bf408c3b1044c41eb43 to your computer and use it in GitHub Desktop.
Save gelilaa/726551e1d3b71bf408c3b1044c41eb43 to your computer and use it in GitHub Desktop.
how to deploy strapi project to Heroku from local-cli

This is a step-by-step guide for deploying a Strapi on heroku. The guide follows the documentation strapi-heroku deployment.

This documentation assumes that you have already created a strapi project with --quickstart and have pushed the repository to Github

Requirements

  1. You must have Git installed and set-up locally .
  2. You must have a free Heroku account before doing these steps.
  3. Download and install the Heroku CLI for your operating system

ForHeroku CLI installation follow this

At this moment Heroku github deployment is not woriking due to internal-server error. For that reason, we will be deploying our project from the local repository to Heroku.

Create an app on heroku

  1. From your browser, navigate to the Heroku dashboard, https://id.heroku.com.
  2. Click New.
  3. Select Create new app.

Login to Heroku from your CLI

Next, you need to login to Heroku from your computer.

heroku login

Follow the instructions and return to your command line.

update .gitignore

add your package-lock.json file path at the end of your .gitignore file

commit your repository and initialize your local project

init your repository and commit the files

cd my-project
git init
git add .
git commit -m "Initial Commit"
git remote add heroku git@heroku.com:my-app.git //change 'my-app with your app's name'

stage, commit, and push changes

Now that your repository is initialized, you can use the following commands to push your changes

git add .
git commit -am "commit message goes here"
git push heroku main

tip: make sure your default branch is main. If not, change accordingly. reference

If everything is runing smoothly until this point, follow the documentation starting from Heroku Postgres

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment