My disk won't work

Hi,

I deployed a Strapi app on Render and am trying to use a disk to store store the content created in Strapi. However, when I restart the service to test it the content is not there anymore.
I tested it locally and it works correctly.

The mount path is “/data”.

Strapi uses sqlite for storage:

sqlite: {
      connection: {
        filename: path.join(
          __dirname,
          "..",
          "..",
          env("DATABASE_FILENAME", "/data/database.sqlite")
        ),
      },
      useNullAsDefault: true,
    },

DATABASE_FILENAME is set to “/data/database.sqlite” both in my local code and on Render.

I checked with Render’s shell and a file “database.sqlite” is created in the data directory.

Thanks for you help.

I’d be suspicious of the path.join there - I suspect you’re probably joining to the current path so you end up in a folder within the repo path. I wonder if you just go rid of the path.join and had:

sqlite: {
      connection: {
        filename: env("DATABASE_FILENAME", "/data/database.sqlite")
      },
      useNullAsDefault: true,
    },

perhaps?

Yes, that was the problem indeed. Found a similar topic in the forum with the same solution and managed to test it successfully. Thank you!

1 Like