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: Run a local PostgreSQL instance in Docker #230

Merged
merged 9 commits into from
Jan 26, 2022
Merged

Conversation

dhess
Copy link
Member

@dhess dhess commented Jan 25, 2022

Fixes #229.

@dhess dhess changed the title chore(nix): Bump dependencies. feat: Run a local PostgreSQL instance in Docker Jan 25, 2022
We need this to get a version of colima that runs on Linux.
@dhess dhess force-pushed the dhess/postgres-docker branch from 94e027a to 378f17d Compare January 25, 2022 15:44
dhess added 2 commits January 25, 2022 17:19
This uses `colima` to create the VMs used by the `docker` executable,
so the user need not have Docker installed, though it should co-exist
with Docker (via the use of Docker contexts) if they do.

The configuration makes use of a persistent Docker volume, so the
database should survive a container restart (and even a PostgreSQL
version upgrade).

This is all pretty imperative, but I don't know of a good way around
that which is also portable.

Docs are forthcoming in a subsequent commit.
@dhess
Copy link
Member Author

dhess commented Jan 25, 2022

@brprice This works great on macOS. Can you test it on Linux? Mainly I just need to know whether colima works on Linux as it does on macOS, so if you can create the container, run it, create an empty DB, and connect to it with run-primer, that will be sufficient. (There are no code changes here, so there's no need to test that database operations work, other than connecting to an empty DB on startup.)

If everything's working, when you get to and execute the nix run .#run-primer step, you should see something like this:

 nix run .#run-primer
trace: To make project.plan-nix for haskell-project a fixed-output derivation but not materialized, set `plan-sha256` to the output of the 'calculateMaterializedSha' script in 'passthru'.
trace: To materialize project.plan-nix for haskell-project entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
trace: Nix Primer version is 594f2824e612ec634374fca6ecf741f3f71988f8
Starting server on port 8081

Instructions are in the README. Thanks!

@dhess dhess requested a review from brprice January 25, 2022 22:22
Comment on lines +35 to +36
reason. The container & database those commands create will persist
across reboots, and will remain on your system until you delete them.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth mentioning where they live / how to delete them?

README.md Outdated Show resolved Hide resolved
README.md Outdated
Comment on lines 81 to 83
This script runs the `primer-postgres` container. The container will
keep running until you reboot your host machine, or you stop the
container yourself.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be worth saying how to stop the container

These are useful for debugging Docker issues.
@dhess
Copy link
Member Author

dhess commented Jan 26, 2022

This needs a little more documentation and then it'll be ready to go.

dhess added 3 commits January 26, 2022 20:55
There were some issues with the previous versions, which I've now
addressed.

I also added a script to stop the container.
@dhess dhess merged commit cf72733 into main Jan 26, 2022
@dhess dhess deleted the dhess/postgres-docker branch January 26, 2022 21:34
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.

Add an easy way to run PostgreSQL locally
2 participants