Skip to content

Commit

Permalink
update (full-stack/postgres): refinement of the instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
santanche committed Sep 4, 2024
1 parent 13c0052 commit 804ab47
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
28 changes: 22 additions & 6 deletions full-stack/1-postgresql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~
Expand All @@ -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
Expand All @@ -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

~~~
Expand All @@ -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
~~~

~~~
4 changes: 2 additions & 2 deletions full-stack/1-postgresql/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
6 changes: 0 additions & 6 deletions full-stack/2-sqlmodel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 804ab47

Please sign in to comment.