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.
-
SQLite and Uploads on Disk: this option will use a Render persistent disk to store both a SQLite database file and uploaded media library files. This is a simple and inexpensive approach, appropriate if, for example, you’re using Strapi as the data source for a static site generator. See Render’s
strapi-sqlite
repository for an example of this approach. -
Managed PostgreSQL and Uploads on Cloudinary: if you’re using Strapi as the backend for a website or app that dynamically fetches content, scalability and availability are more important. Use a managed PostgreSQL database and Cloudinary for uploads to get horizontal scaling and zero downtime deploys. See Render’s
strapi-postgres-cloudinary
repository for an example of this approach. -
Managed PostgreSQL and Uploads on Disk: if you care about performance but can tolerate a few seconds of downtime when you deploy, you can cut costs compared to a paid Cloudinary plan with a hybrid approach. Use managed PostgreSQL for structured content and block storage for uploads. If your project doesn’t use the media library you can remove the disk to get horizontal scaling and zero downtime deploys. See Render’s
strapi-postgres
repository for an example of this approach.
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
- Commit your changes and push them to GitHub or GitLab.
- In the Render dashboard select YAML in the side navigation and click the New From YAML button.
- Give Render permission to access your GitHub or GitLab repository if you haven’t already.
- 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.