Adding a local PostgreSQL database

Back To Blog

In this tutorial we will add a PostgreSQL database in the db/ folder working in an opeNode instance. It is worth noting that it will consume at least 20 MB extra memory, so if you use for instance the smallest instance plan, it is recommended to increase your plan. You can enable PostgreSQL by running the following command:

openode template --with-services postgresql

This command will add a postgresql setup in your docker-compose.yml file, with a default user password and database name, which can be modified. More variables can be passed, see

Also make sure to create a storage area so that it don't get deleted by our system:

openode add-storage-area db/

And also make sure to ignore that folder by creating an .openodeignore file with:


We tested it with a simple Node.js application, please see this repository, the PostgreSQL code is located in server.js (Notice that it just creates a database and basic table).

Important Notice:

Note that it is NOT recommended to use a database as described in this doc, it is recommended to use an external database service.

When you redeploy, make sure to first:

openode stop

and then deploy:

openode deploy

If you do not stop it first, it might corrupt your database storage, as we do blue-green deployments and when it is redeploying, 2 instances of your site is running in parallel.

You could consider to sync and reload instead:

openode sync
openode reload

Added on Tue Dec 11 2018 02:34:22 GMT+0000 (Coordinated Universal Time)