Render Deployment

This guide explains how to update an existing Strapi project so it can be deployed on Render.

With persistent disks and managed PostgreSQL databases, Render gives you multiple different ways to store your content. Render services come with fully managed SSL, so it’s no longer necessary to set up a proxy server to secure your Strapi app. Since Render services are automatically restarted if they become unresponsive, you don’t need to use a process manager like pm2 either.

For more information consult Render’s Deploy Strapi guide.

Step 1: Create a Render Account

Visit the Render dashboard to create an account if you don’t already have one.

Step 2: Choose Your Content Storage Method

You have to choose which database system to use for storing structured content, and where to store uploaded media library files.

Below are descriptions of 3 approaches that make different trade-offs between scalability, availability, simplicity, and cost.

Step 3: Add a render.yaml File

Select the render.yaml file that matches your storage preferences and add it to the root of your Strapi project.

strapi-sqlite

services:
  - type: web
    name: strapi
    env: node
    plan: starter
    buildCommand: yarn install && yarn build
    startCommand: rsync -a public/ /data/public/ && yarn start
    healthCheckPath: /_health
    disk:
      name: strapi-data
      mountPath: /data
      sizeGB: 1
    envVars:
      - key: NODE_VERSION
        value: 12.22.0
      - key: NODE_ENV
        value: production
      - key: DATABASE_FILENAME
        value: /data/strapi.db
      - key: JWT_SECRET
        generateValue: true
      - key: ADMIN_JWT_SECRET
        generateValue: true
      - key: APP_KEYS
        generateValue: true
      - key: API_TOKEN_SALT
        generateValue: true

strapi-postgres-cloudinary

services:
  - type: web
    name: strapi
    env: node
    plan: starter
    buildCommand: yarn install && yarn build
    startCommand: yarn start
    healthCheckPath: /_health
    envVars:
      - key: NODE_VERSION
        value: 12.22.0
      - key: NODE_ENV
        value: production
      - key: CLOUDINARY_NAME
        sync: false
      - key: CLOUDINARY_KEY
        sync: false
      - key: CLOUDINARY_SECRET
        sync: false
      - key: DATABASE_URL
        fromDatabase:
          name: strapi
          property: connectionString
      - key: JWT_SECRET
        generateValue: true
      - key: ADMIN_JWT_SECRET
        generateValue: true
      - key: APP_KEYS
        generateValue: true
      - key: API_TOKEN_SALT
        generateValue: true

databases:
  - name: strapi
    plan: starter

strapi-postgres

services:
  - type: web
    name: strapi
    env: node
    plan: starter
    buildCommand: yarn install && yarn build
    startCommand: yarn start
    healthCheckPath: /_health
    disk:
      name: strapi-uploads
      mountPath: /opt/render/project/src/public/uploads
      sizeGB: 1
    envVars:
      - key: NODE_VERSION
        value: 12.22.0
      - key: NODE_ENV
        value: production
      - key: DATABASE_URL
        fromDatabase:
          name: strapi
          property: connectionString
      - key: JWT_SECRET
        generateValue: true
      - key: ADMIN_JWT_SECRET
        generateValue: true
      - key: APP_KEYS
        generateValue: true
      - key: API_TOKEN_SALT
        generateValue: true

databases:
  - name: strapi
    plan: starter

Alternatively, you can manually configure your service and database in the Render dashboard, instead of using infrastructure as code.

Step 4: Configure Strapi for Production

Copy config/env/production and its contents from the example repository that corresponds to your storage preference.

If you attach a custom domain to your Render service, use it as the url attribute in server.js.

For PostgreSQL, install the pg package from npm. If you’re using Cloudinary, install strapi-provider-upload-cloudinary.

The Configuration doc has more info on configuring Strapi.

Step 5: Deploy

  1. Commit your changes and push them to GitHub or GitLab.
  2. In the Render dashboard select YAML in the side navigation and click the New From YAML button.
  3. Give Render permission to access your GitHub or GitLab repository if you haven’t already.
  4. Select the repository and branch for your Strapi project and follow the prompts that appear. If you’re using Cloudinary, you’ll be asked to enter your account credentials as environment variables. Render encrypts environment variables and stores them securely.

Step 6: Scale

For vertical scaling, upgrade your service to a plan with more CPU and RAM per instance. If you’re using a managed database you can upgrade its plan as well. Visit Render’s pricing page and consider the recommended requirements in choosing the best plan for your needs. To upgrade, change the plan field(s) in your render.yaml file.

Render services without attached disks can be horizontally scaled. Add a numInstances field in your render.yaml file to get multiple instances of your Strapi application running in parallel. Render automatically load balances requests among your instances.

For manually-managed infrastructure you can change the plan and number of instances from the Settings tab in the Render dashboard.

Hi,

I’ve seem to have an issue with the strapi-sqlite example whereby the strapi.db file isn’t being written to the persistent disk.

I’ve created a thread with full details here:

But in short, the strapi.db is being written to the /data folder within the project and not the one at root level of the server (where the persistent disk is)

I’m don’t know if this is a config issue, or perhaps a problem within Strapi or Render, but any help on the matter would be greatly appreciated.

Many thanks,
Chris

You can also use supabase in its free option to host your database. In this guide you can see how to create your postgreSQL database in supabase, and upload it to render, using free options.