.postgresql/root.crt missing

I have a build file that looks like this:

#!/usr/bin/env bash
set -o errexit

mkdir -p /opt/render/.postgresql/
if [ ! -f /opt/render/.postgresql/root.crt ]; then
    cp /etc/secrets/postgresql-root.crt /opt/render/.postgresql/root.crt

pip install -U pip
pip install -r requirements.txt
python manage.py collectstatic --no-input
mkdir -p staticfiles
python manage.py migrate

My render.yaml looks like this:

  - type: web
    name: backend
    env: python
    buildCommand: "./build.sh"
    startCommand: "gunicorn backend.wsgi:application"

Whenever I deploy, .postgresql/root.crt get’s wiped. I can verify the file does exist in /etc/secrets/, and when I manually copy it in the command-line post deploy everything works again.

Is there some type of gotcha around creating files & folders in /opt/render/? Is there some type of “post-build” step or should I move this to the start command?


Hi there,

Thanks for reaching out.

You’re likely creating the folder too high up the structure. I think only the /opt/render/project folder is taken from the build to generate the image. You’ll either need to move your files under that folder to be stored as part of the build, or it may be more straightforward to set it up as part of your Start Command, as you suggested.

Kind regards


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