From 804ab471d0e919bb835586f586314d94a1e69d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Santanch=C3=A8?= Date: Wed, 4 Sep 2024 10:16:51 -0300 Subject: [PATCH] update (full-stack/postgres): refinement of the instructions --- full-stack/1-postgresql/README.md | 28 +++++++++++++++++----- full-stack/1-postgresql/docker-compose.yml | 4 ++-- full-stack/2-sqlmodel/README.md | 6 ----- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/full-stack/1-postgresql/README.md b/full-stack/1-postgresql/README.md index 3537c68..065f902 100644 --- a/full-stack/1-postgresql/README.md +++ b/full-stack/1-postgresql/README.md @@ -5,7 +5,18 @@ https://www.postgresql.org Image: https://hub.docker.com/_/postgres -The `docker-compose.yml` has the instruction for docker compose. To run: +The `docker-compose.yml` has the instructions for "docker compose": + +* It departs from the Postgres Docker image. +* It is meant to be a local configuration of the docker image and must be adapted to the deployment server. +* In the `ports` section, it redirects the default Postgres port (`5432`) to another one (`5421`), avoiding port collision in case you have a PostgreSQL installed on your machine (optional). +* It maps two internal (docker machine) folders to external (host machine) ones. + * The default internal docker database folder (`/var/lib/postgresql/data`) is mapped to the external: `/home/user/data/pgsql/docker`. + * The internal home directory (`/home`) is mapped to the external: `/home/user/data/pgsql/impexp`. This directory is meant to manage files imported/exported. + * You must adjust the external directory to your machine folder structure. +* The `restart` clause considers the local dev environment (it does not restart whenever you turn the machine on). In the server configuration, we suggest replacing it with `restart: always`. + +To run: ~~~ docker compose up ~~~ @@ -14,7 +25,7 @@ docker compose up ~~~ docker exec -it 1-postgresql-db-1 bash -psql -U postgres test +psql -U postgres citizen ~~~ # PostgreSQL on Ubuntu @@ -33,6 +44,12 @@ apt install postgresql To install the latest one, follow the instructions of "manually configure the Apt repository". +## pgAdmin +https://www.pgadmin.org/ + +Detailed instructions to install pgAdmin via apt: +https://www.pgadmin.org/download/pgadmin-4-apt/ + ## Changing the Password ~~~ @@ -56,11 +73,10 @@ Reference: https://tableplus.com/blog/2018/10/how-to-start-stop-restart-postgres To change the database location at Ubuntu: https://www.digitalocean.com/community/tutorials/how-to-move-a-postgresql-data-directory-to-a-new-location-on-ubuntu-20-04 - # SQL Model -Schema related to the base data model in SQL, the insertion of three tuples: +Schema related to the base data model in SQL, the insertion of three tuples: + ~~~ users_schema.sql -~~~ - +~~~ \ No newline at end of file diff --git a/full-stack/1-postgresql/docker-compose.yml b/full-stack/1-postgresql/docker-compose.yml index f042a75..4eb12ba 100644 --- a/full-stack/1-postgresql/docker-compose.yml +++ b/full-stack/1-postgresql/docker-compose.yml @@ -18,11 +18,11 @@ volumes: driver: "local" driver_opts: type: "none" - device: "/home/santanche/data/pgsql/docker" + device: "/home/user/data/pgsql/docker" o: "bind" postgres-impexp: driver: "local" driver_opts: type: "none" - device: "/home/santanche/data/pgsql/impexp" + device: "/home/user/data/pgsql/impexp" o: "bind" diff --git a/full-stack/2-sqlmodel/README.md b/full-stack/2-sqlmodel/README.md index 1e8075c..ab86471 100644 --- a/full-stack/2-sqlmodel/README.md +++ b/full-stack/2-sqlmodel/README.md @@ -21,12 +21,6 @@ https://pypi.org/project/psycopg2/ pip install psycopg2 ~~~ -# pgAdmin -https://www.pgadmin.org/ - -Detailed instructions to install pgAdmin via apt: -https://www.pgadmin.org/download/pgadmin-4-apt/ - # Simple Example A simple and complete example of defining a model, creating a table, and inserting three records. There are two versions: