RSS Amplifier

dhilst · May 25, 2021

Faster tests with tmpfs Database and Docker

0
Sign in to vote or save

This page cannot be shown here. You can still read it on the original site — the toolbar below keeps your place in the directory.

Here is how to creating a Postgres database in memory for testing! On your docker-compose replace the volume folder by a tmpfs entry, and you’re done. diff --git a/src/docker-compose-dev.yml b/src/docker-compose-dev.yml index ead4090..7a10881 100644 --- a/src/docker-compose-dev.yml +++ b/src/docker-compose-dev.yml @@ -82,4 +82,5 @@ services: volumes: - - pg_dbdata:/var/lib/postgresql/data -…

Here is how to creating a Postgres database in memory for testing!

On your docker-compose replace the volume folder by a tmpfs entry, and you’re done.

diff --git a/src/docker-compose-dev.yml b/src/docker-compose-dev.yml
index ead4090..7a10881 100644
--- a/src/docker-compose-dev.yml
+++ b/src/docker-compose-dev.yml
@@ -82,4 +82,5 @@ services:
     volumes:
-      - pg_dbdata:/var/lib/postgresql/data
       - ${PWD}/scripts/db/init/:/docker-entrypoint-initdb.d/
+    tmpfs:
+      - /var/lib/postgresql/data
     networks:

There are some drawbacks, the database will be reseted when the host machine is rebooted, but for automating test this is okay! :)

Cheers!

Read on dhilst.github.com

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.