Automatically run Postgres via container in local dev? #5
Labels
No Label
admins only
bug
design
duplicate
gimme feedback
good first issue
hmmmm
invalid
reference
wontfix
No Milestone
No Assignees
1 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: hmn/hmn#5
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
We want the HMN website to be pretty much plug-and-play in local development, which means we don't want the user to have to run lots of confusing scripts. An example of this is our
db seed
command, which tries to log in as root using common defaults and will then drop / recreate the database and user. Normally the user would have to do this manually, involving the confusing process of getting intopsql
and running commands manually, possibly needing to drop things first. We can avoid most of that pain, which is nice.But, Postgres does not actually just ship with a default root password on most installations. This makes it essentially impossible for us to work this magic. Two options come to mind:
The latter is appealing to me, but unfortunately this seems to be nearly impossible because Postgres doesn't like to run as a plain old program - it needs a "cluster" and background services and a bunch of other nonsense. However, containers make this fairly easy, assuming the user has a container runtime handy. For example, the official Docker image for Postgres not only can be started up / shut down using the usual Docker commands (
run
,ps
,stop
) but it can have the root password configured by environment variable. I assume podman works the same way (and that there is another sane container registry in the world in preparation for Docker's inevitable demise).If we think this is viable and not too difficult, the HMN website could simply detect the presence of a functional container runtime and run Postgres on its own in the background as necessary.
Questions I would want to answer before doing this:
On further thought I think this probably is worth doing. I don't think it would be that hard to recognize e.g. Docker and Podman and just give it a go. There really are a lot of advantages for controlling local dev this way,