Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow persistent data in postgres test #23

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ForbesLindesay
Copy link
Owner

The idea is to build a very simple CLI that lets you do something like:

pg-test start --persistVolume my-database --writeEnv .env.local

and it would start a database and put the DATABASE_URL for the freshly started database in .env.local and persist data as a my-database volume in docker.

Questions

  1. How should we name the containers? Currently we default to pg-test for all containers so we automatically shut down old containers when running new ones. Maybe we should use the volume name when one is provided? Maybe we should include the current directory name?
  2. If you have lots of projects using separate pg databases, it might be easy to start one pointing at the wrong port number. Could we hash the volume-name and use that to decide on the port number?
    • Port numbers range from 0 to 65535 (i.e. 16 bits), but port numbers 0 to 1023 are reserved for privileged services and designated as well-known ports. Registered ports are 1024 to 49151. Dynamic ports (also called private ports) are 49152 to 65535. (https://www.webopedia.com/quick_ref/portnumbers.asp)
    • generate-alphabetic-name can generate a 32 bit numeric hash from any string
    • If we can evenly distribute across the remaining 16383 port numbers that are available for general use, we can probably fairly consistently pick different ports for different volume names.

Docker Commands

You can see the volumes via:

docker volume ls

You can delete a volume via:

docker volume rm my-database

@rollingversions
Copy link

rollingversions bot commented Apr 27, 2020

There is no change log for this pull request yet.

Create a changelog

@ForbesLindesay ForbesLindesay force-pushed the feat/persistent-test branch 2 times, most recently from d75d821 to 83c589f Compare May 2, 2020 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant