Confusion between preview env & Pull Request Previews

Hi there,

I’m currently setting up pull request previews for my app (elixir/docker service + PG database).

I have to admit that I have been really confused by the preview environment documentation which seems to be a different concept than PR previews.

So if I understand this well, all previewValue, previewPlan … keys are ignored by PR previews?

I would like to make my PR web service use my PR database:

  • am I supposed to manually update environment vars using a initialDeployHook and your API?
  • should I also downgrade my application plan using a hook + API?

Thanks for your help,
Christian

Hi Christian,

You’re right that preview environments are different from PR previews. PR previews only create a preview instance of the service they are for and are only available for web and static services. They DO NOT create separate databases, they would use the same environment variables as the parent instance as detailed in https://render.com/docs/pull-request-previews#how-pull-request-previews-work.

Preview environments use your render.yaml definition and create preview instances of all your defined services and databases. So if you have a web service and a database defined, you would get a preview environment which contains these 2 services and then when the pull request is merged the environment is destroyed. If your webservice refers to the connection string of the database in the render.yaml then when the preview environment is created then the preview environment webservice will be linked to the preview environment database that was created for you. Also, preview environments support the plan overrides as detailed at https://render.com/docs/preview-environments#override-preview-plans.

Personally, I would always use preview environments, I don’t think I’ve ever used a PR preview myself,

I hope that clears things up?

John B

1 Like

Yes it indeed clears things up!
So I will switch back to preview environments, thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.