Deployment

Strapi gives you many possible deployment options for your project or application. Strapi can be deployed on traditional hosting servers or services such as Heroku, AWS, Azure and others. The following documentation covers how to develop locally with Strapi and deploy Strapi with various hosting options.

(Deploying databases along with Strapi is covered in the Databases Guide.)

Table of contents:


Configuration

#1 - Configure

Update the production settings with the IP and domain name where the project will be running.

Path — ./config/environments/production/server.json.

{
  "host": "domain.io", // IP or domain
  "port": 1337,
  "autoReload": {
    "enabled": false
  },
  "admin": {
    "path": "/dashboard" // We highly recommend to change the default `/admin` path for security reasons.
  }
}

In case your database is not running on the same server, make sure that the environment of your production database (./config/environments/production/database.json) is set properly.

If you are passing a number of configuration item values via environment variables which is always encouraged for production environment to keep application stateless, checkout the section for Dynamic Configuration. Here is a hint on how to do it for production, for the configuration mentioned above:

Path — ./config/environments/production/server.json.

{
  "host": "${process.env.APP_HOST || '127.0.0.1'}"
  "port": "${process.env.NODE_PORT || 1337}",
  "autoReload": {
    "enabled": false
  },
  "admin": {
    "path": "/dashboard" // We highly recommend to change the default `/admin` path for security reasons.
  }
}

⚠️ If you changed the path to access to the administration, the step #2 is required.

#2 - Setup (optional)

Run this following command to install the dependencies and build the project with your custom configurations.

cd /path/to/the/project
npm run setup

To display the build logs use the --debug option npm run setup --debug.

#3 - Launch the server

Run the server with the production settings.

NODE_ENV=production npm start

WARNING

We highly recommend to use pm2 to manage your process.

Advanced configurations

If you want to host the administration on another server than the API, please take a look at this dedicated section.

Heroku

This is a step-by-step guide for deploying a Strapi project on Heroku. Databases that work well with Strapi and Heroku are provided instructions on how to get started.

Heroku Install Requirements

If you already have the Heroku CLI installed locally on your computer. Skip to Login to Heroku.

1. Heroku CLI Installation

Download and install the Heroku CLI for your operating system:

    2. 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.

    3. Create a new project (or use an existing one)

    Create a new Strapi project (if you want to deploy an existing project go to step 4).

    NOTE

    If you plan to use MongoDB with your project, refer to the create a Strapi project with MongoDB section of the documentation then, jump to step 4.

    Path: ./

    strapi new my-project --quickstart
    

    Note: When you use --quickstart to create a Strapi project locally, a SQLite database is used which is not compatible with Heroku. Therefore, another database option must be chosen.

    4. Update .gitignore

    Add the following line at end of .gitignore:

    Path: ./my-project/.gitignore

    package-lock.json
    

    Even if it is usually recommended to version this file, it may create issues on Heroku.

    5. Init a Git repository and commit your project

    Init the Git repository and commit yoru project.

    Path: ./my-project/

    cd my-project
    git init
    git add .
    git commit -am "Initial Commit" 
    

    6. Create a Heroku project

    Create a new Heroku project.

    Path: ./my-project/

    heroku create
    

    (You can use heroku create custom-project-name, to have Heroku create a custom-project-name.heroku.com URL. Otherwise, Heroku will automatically generating a random project name (and URL) for you.)

    NOTE

    If you have a Heroku project app already created. You would use the following step to initialize your local project folder:

    Path: ./my-project/

    heroku git:remote -a your-heroku-app-name
    

    Your local development environment is now set-up and configured to work with Heroku. You have a new Strapi project and a new Heroku app ready to be configured to work with a database and with each other.

    7. Heroku Database set-up

    Below you will find database options when working with Heroku. Please choose the correct database (e.g. PostgreSQL, MongoDB, etc.) and follow those instructions.

      8. Commit your changes

      Path: ./my-project/

      git commit -am "Update database config"
      

      9. Deploy

      Path: ./my-project/

      git push heroku master
      

      The deployment may take a few minutes. At the end, logs will display the url of your project (e.g. https://mighty-taiga-80884.herokuapp.com). You can also open your project using the command line:

      Path: ./my-project/

      heroku open
      

      If you see the Strapi Welcome page, you have correctly set-up, configured and deployed your Strapi project on Heroku. You will now need to set-up your admin user as the production database is brand-new (and empty).

      You can now continue with the Tutorial - Creating an Admin User, if you have any questions on how to proceed.

      NOTE

      For security reasons, the Content Type Builder plugin is disabled in production. To update content structure, please make your changes locally and deploy again.


      Project updates

      As you continue developing your application with Strapi, you may want to use version control, or you can continue to use Git push heroku master to commit and push changes to Heroku directly.

      Path: ./my-project/

      git add .
      git commit -am "Changes to my-project noted"
      git push heroku master
      heroku open
      

      Docker

      TIP

      You can also deploy using Docker

      The method below describes regular deployment using the built-in mechanisms.