Development → Staging → Production render.yml example

Hi Render community, I’m setting up a Strapi backend and want to get running with the three environments, looking at the documentation here:

There’s no indication of how to configure the render.yml file, anyone here able to give any guidance on what to add if I want to add a production, staging and dev environments to the render.yaml that comes with the starter?

Also note to the documentation owners for that linked page to add that information there for future me and other users :+1:

You can refer to this paragraph

If you’d like to set up a staging environment on Render, you can update the render.yaml file at the root of your repository and add staging resources that are similar to your production resources. You might want to change the name field to something like strapi-staging and the NODE_ENV environment variable to staging . You might also want to use less expensive service and database plans in staging

In short, the staging environment should as close to production as possible. Therefore you can duplicate all contents in render.yaml and add a different name like strapi-staging. When you deploy with this YAML, Render will create both production and staging strapi server and database.
Another option is using 2 YAML files, one for production and one for staging. These 2 files can be identical except name fields.

1 Like

Ok cool, so taking a look at the linked .yml file, will I be able to do this:

services:
  - type: web
    name: strapi-dev
    env: node
    plan: starter
    buildCommand: yarn install && yarn build
    startCommand: yarn start
    healthCheckPath: /_health
    envVars:
      - key: NODE_VERSION
        value: 12.18.4
      - 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-dev
          property: connectionString
      - key: JWT_SECRET
        generateValue: true
      - key: ADMIN_JWT_SECRET
        generateValue: true
  - type: web
    name: strapi-staging
    env: node
    plan: starter
    buildCommand: yarn install && yarn build
    startCommand: yarn start
    healthCheckPath: /_health
    envVars:
      - key: NODE_VERSION
        value: 12.18.4
      - 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-staging
          property: connectionString
      - key: JWT_SECRET
        generateValue: true
      - key: ADMIN_JWT_SECRET
        generateValue: true
  - type: web
    name: strapi-production
    env: node
    plan: starter
    buildCommand: yarn install && yarn build
    startCommand: yarn start
    healthCheckPath: /_health
    envVars:
      - key: NODE_VERSION
        value: 12.18.4
      - 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-production
          property: connectionString
      - key: JWT_SECRET
        generateValue: true
      - key: ADMIN_JWT_SECRET
        generateValue: true

databases:
  - name: strapi-dev
  - name: strapi-staging
  - name: strapi-production

I think that this should be reflected in the documentation because it’s not very clear how to do this, although it is a recommended approach.

If you could confirm that the format is correct then I’ll go on my way

thanks

Can you be a bit more explicit on this please?

Actual examples to follow would be really helpful so there’s no confusion, because from whay you’re saying I have no idea what to call the second yaml file if I were to have one for dev and prod, how would Render know what file was what?

Thanks :pray:

This is an example (I usually do development on my laptop, so I don’t need to deploy DEV environment to Render.)

In Render Dashboaard, click YAML → New from YAML → input my github repo URL

Enter needed environment variables for production and staging

After clicking “Apply”, Render will create a production service, production database, staging service, and staging database.

Now you have your staging and production service




1 Like

Ok, cool, cool!

Thanks for the example :pray:

I really like infrastructure as code

Is there a way to do this with a preview environment? Dev/staging/prod should be the same except for resource size and env variables

Hi Ben,

We do support overriding plans and environment variables with Preview Environments.