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

Utiliser une socket UNIX pour se connecter à la base de données en dev #5455

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
image: postgis/postgis:15-master
env:
POSTGRES_PASSWORD: password
ports:
- 5432:5432
volumes:
- /var/run/postgresql:/var/run/postgresql
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
Expand All @@ -46,6 +46,10 @@ jobs:
--health-retries 5

steps:
- name: Setup PostgreSQL environment
run: |
echo PGHOST=/var/run/postgresql >> $GITHUB_ENV
echo PGUSER=postgres >> $GITHUB_ENV
- name: 🐘 Non-durable PostgreSQL
run: |
psql <<SQL
Expand All @@ -54,10 +58,6 @@ jobs:
ALTER SYSTEM SET full_page_writes=off;
SQL
docker kill --signal=SIGHUP ${{ job.services.postgres.id }}
env:
PGPASSWORD: password
PGHOST: localhost
PGUSER: postgres
- uses: actions/[email protected]
- name: 🌍 Install spatial libraries
run: sudo apt-get update && sudo apt-get install binutils build-essential libproj-dev gdal-bin
Expand All @@ -66,10 +66,6 @@ jobs:
psql <<SQL
CREATE DATABASE itou;
SQL
env:
PGPASSWORD: password
PGHOST: localhost
PGUSER: postgres
- name: 💂 Install Python
uses: actions/setup-python@v5
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ envs/secrets.env

# Config
docker-compose-prod.yml
docker/dev/postgres/
docker/prod/

# Project specific
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ services:
shm_size: 1g
volumes:
- postgres_data:/var/lib/postgresql/data
- type: bind
source: ${PWD}/docker/dev/postgres
target: /var/run/postgresql/
restart: unless-stopped
ports:
- "127.0.0.1:${POSTGRES_PORT_ON_DOCKER_HOST:-5432}:5432"
Expand Down
16 changes: 16 additions & 0 deletions docs/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ arguments pour se connecter à la base de données.
Les variables suivantes permet d’accéder à la base de données définie dans le
[docker-compose.yml](../docker-compose.yml) simplement avec la commande `psql`.

Deux options:

#### Socket UNIX

La plus performante, et devrait bien fonctionner sur les systèmes
[*nix](https://fr.wikipedia.org/wiki/Type_Unix).

```bash
export PGDATABASE=itou
export PGHOST="${PWD}/docker/dev/postgres"
export PGUSER=postgres
# La connexion par la socket est autorisée par défaut.
```

#### TCP

```bash
export PGDATABASE=itou
export PGHOST=localhost
Expand Down
Loading