3 ms·
"Just starting a postgres" is possible but it's a lot harder than it should be. Generally, you can just run the `postgres` command, but it creates many unneces
by nh2 3y ago
"Just starting a postgres" is possible but it's a lot harder than it should be.
Generally, you can just run the `postgres` command, but it creates many unnecessary hurdles:
* Just want to invoke `postgres`? Not possible, you need to invoke `initdb` first. Why can't `postges` do that for automatically you if the DB dir doesn't exist, like other servers do (e.g. `consul`)?
* Depending on your invocation, you're likely to run into errors mentioning "initdb: invalid locale settings; check LANG and LC_* environment variables". Why isn't there a simple UTF-8 default?
* Postgres refuses to run as `root`; that's unoverridably hardcoded in its code. So you can't "just start it" when you're `root` inside a container or VM in which only postgres runs. It can't run well under `unshare` when you want things to shut down reliably on cancellation in CI. This constraint should just be removed; no other software refuses to run as root. This mindset is indeed from 27 years ago.
* You can't start an in-memory postgres for quick testing or CI. This feature does not exist.
All of this is fixable, but it currently creats the "oh you can 'just run' postgres, but not in random conditions A, B, C and D".
- returningfory2 3y agoI think just running Postgres via the standard Docker image solves most of these issues. Also an in memory Postgres would be nice, but Docker again gives an easy way of setting up “throwaway Postgresses”. This all assumes Linux ofc.
- DANmode 3y agoThat doesn't sound super friendly for local development env/prototyping when swathes of webdevs literally don't even know what Docker is, today.
- 5Qn8mNbc2FNCiVV 3y agoI always put a docker-compose.yaml into the repo and in the readme some instructions to install docker and docker-compose and that they should run `docker-compose up` Works fine for almost any team. Obviously it would be great if they would try to understand it, but it's really not necessary. Not like most web devs know how most of the tools they use work (Source: All the teams I worked at)
- Too 3y ago“docker run -ti -p 5412 postgres”? Easy enough to type on my phone. That downloads and starts everything you need and wipes the data on exit. Ideal for prototyping. If you want to keep the data, add some -v flag or use a compose file as suggested below, even easier. Devs not knowing docker? Just install docker on their machine and ask them run the command above. One day has to be the first.