Adding a local MariaDB (MySQL) database

Back To Blog

In this tutorial we will add a MariaDb (Mysql) database in the db/ folder. It is worth noting that it will consume at least 50-100 MB extra memory, so if you use for instance the smallest instance plan, it is recommended to increase your plan. You can enable MySQL by adding the following instructions in your docker-compose.yml:

    image: mariadb
      - /opt/app/db/:/var/lib/mysql/
      MYSQL_DATABASE: mydb

It can also be generated automatically by running:

openode template --with-services mariadb

Further, make sure to define a storage area so that it does not get deleted on updates (persistent):

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 hello world, please see this repository.

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 Sun Nov 25 2018 21:10:28 GMT+0000 (Coordinated Universal Time)