How to dockerize a local postgres database for tests

Apologies for the late reply, just to add to what @ajcwebdev already said: Supabase’s can be used locally or when self hosting. I use it locally and it isn’t any harder to setup than ‘vanilla’ Postgres is, not sure if the extensions are plug-and-play to be honest.

I also noticed your question here, have you considered using a named volume instead of mounting a directory from the host? That way your database’s persisted data isn’t actually stored alongside the application.

Your docker-compose.yml would just need an update:

version: '3.7'
services:
    postgres:
        image: postgres:10.5
        restart: always
        environment:
          - POSTGRES_USER=postgres
          - POSTGRES_PASSWORD=postgres
        logging:
          options:
            max-size: 10m
            max-file: "3"
        ports:
          - '5438:5432'
        volumes:
          - postgres_data:/var/lib/postgresql/data
volumes:
  postgres_data: