Use postgresql and pgadmin

This commit is contained in:
ManUtopiK 2022-10-20 15:30:07 +02:00
parent a7009de96c
commit 0c2e1d2c2c
5 changed files with 80 additions and 0 deletions

19
.env.example Normal file
View File

@ -0,0 +1,19 @@
GENERIC_TIMEZONE=Europe/Paris
POSTGRES_USER=changeUser
POSTGRES_PASSWORD=changePassword
POSTGRES_DB=n8n
POSTGRES_NON_ROOT_USER=changeUser
POSTGRES_NON_ROOT_PASSWORD=changePassword
SMTP_HOST=smtp.gmail.com
SMTP_USER=emmanuel.salomon@gmail.com
SMTP_PASS=nckctwxxqlidotss
SMTP_SENDER=contact@manutopik.fr
N8N_BASIC_AUTH_USER=changeUser
N8N_BASIC_AUTH_PASSWORD=changePassword
N8N_WEBHOOK_URL=https://n8n.manutopik.fr
HASURA_GRAPHQL_ADMIN_SECRET=changePassword

22
composes/db/compose.yml Normal file
View File

@ -0,0 +1,22 @@
services:
db:
image: postgres:14
restart: always
environment:
- POSTGRES_USER
- POSTGRES_PASSWORD
- POSTGRES_DB
- POSTGRES_NON_ROOT_USER
- POSTGRES_NON_ROOT_PASSWORD
volumes:
- db_storage:/var/lib/postgresql/data
- ./init-data.sh:/docker-entrypoint-initdb.d/init-data.sh
healthcheck:
test:
[
'CMD-SHELL',
'pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}',
]
interval: 5s
timeout: 5s
retries: 10

12
composes/db/init-data.sh Normal file
View File

@ -0,0 +1,12 @@
#!/bin/bash
set -e;
if [ -n "${POSTGRES_NON_ROOT_USER:-}" ] && [ -n "${POSTGRES_NON_ROOT_PASSWORD:-}" ]; then
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE USER ${POSTGRES_NON_ROOT_USER} WITH PASSWORD '${POSTGRES_NON_ROOT_PASSWORD}';
GRANT ALL PRIVILEGES ON DATABASE ${POSTGRES_DB} TO ${POSTGRES_NON_ROOT_USER};
EOSQL
else
echo "SETUP INFO: No Environment variables given!"
fi

View File

@ -0,0 +1,13 @@
services:
pgadmin:
container_name: pgadmin
image: dpage/pgadmin4:latest
environment:
- PGADMIN_DEFAULT_EMAIL=${ADMIN_MAIL}
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_PASSWORD}
ports:
- "5050:80"
restart: always
depends_on:
db:
condition: service_healthy

14
docker-compose.yml Normal file
View File

@ -0,0 +1,14 @@
services:
db:
extends:
file: composes/db/compose.yml
service: db
pgadmin:
extends:
file: composes/pgadmin/compose.yml
service: pgadmin
volumes:
db_storage: