diff options
author | Pjotr Prins | 2023-01-17 09:06:18 -0600 |
---|---|---|
committer | Pjotr Prins | 2023-01-17 09:07:59 -0600 |
commit | 4ec7c8a48e22e6e6f436335b6ecb471a929dc50c (patch) | |
tree | 2ed2fe89cd22007b06a558f5b847bf064dfef6b0 | |
parent | 000301551a49cee912c3342ae5510e0b8ee1d95e (diff) | |
download | gn-gemtext-4ec7c8a48e22e6e6f436335b6ecb471a929dc50c.tar.gz |
Postgres in a container
-rw-r--r-- | tasks/pjotrp.gmi | 5 | ||||
-rw-r--r-- | topics/guix/run-postgres-in-container.gmi | 65 |
2 files changed, 68 insertions, 2 deletions
diff --git a/tasks/pjotrp.gmi b/tasks/pjotrp.gmi index 3ebfba7..401ae88 100644 --- a/tasks/pjotrp.gmi +++ b/tasks/pjotrp.gmi @@ -22,8 +22,9 @@ Now * [+] Shelby's application and biosketch * [.] Check Tony's list and improve search for SNPs and Hs * [.] GeneNetwork paper -* [ ] Machine room security and access -* [ ] Tree of life +* [ ] Machine room security and access for bonz, fred, shelby, others... +* [ ] Set up student VM +* [.] Tree of life * [ ] Check backups of etc etc. * [ ] GeneNetwork consortium diff --git a/topics/guix/run-postgres-in-container.gmi b/topics/guix/run-postgres-in-container.gmi new file mode 100644 index 0000000..0d61b31 --- /dev/null +++ b/topics/guix/run-postgres-in-container.gmi @@ -0,0 +1,65 @@ +# Running postgres in a Guix container + +GNU Guix never fails to amaze me. +Here is a simple recipe to run Postgres in userland on a system that has a guix daemon running + +## Steps + +Select a recent version of guix (note the leading dot) + +``` +. ~/opt/guix-pull/etc/profile +``` + +Install postgres (here we opt for v14) with + +``` +guix packages -A postgres +mkdir -p ~/data/pgdata +cd ~/data +guix shell -C -N postgresql@14.4 glibc-locales binutils coreutils which \ + --share=$HOME/data/pgdata --share=/var/run/postgresql +``` + +To share `/var/run` make sure your user id is member of the postgres group. + +Inside the shell + +``` +mkdir -p /var/run/postgresql +initdb -k -D pgdata/14 +pg_ctl -D pgdata/14 -l logfile start +createdb test +psql test +``` + +and you should be able to work with everything. Note the user is the same as the user that runs the container. + +Test then network interface with + +``` +telnet localhost 5432 +``` + +To run a container in the background you may want to use screen and/or tmux. + +To have the postgres client outside the container install it with + +``` +. ~/opt/guix-pull/etc/profile +guix package -i postgresql@14.4 -p ~/opt/postgresql14 +``` + +Now you can add this + +``` +. ~/opt/postgresql14/etc/profile +psql test +\dt +etc etc +``` + +## More + +=> https://fluca1978.github.io/2021/09/30/GNU_GUIX_PostgreSQL.html +=> https://guix.gnu.org/cookbook/en/html_node/A-Database-Container.html |