Initial commit

This commit is contained in:
Nicolas H 2024-07-17 22:59:51 +02:00
commit d9e4d64ee4
Signed by: administrateur
GPG Key ID: 6F1745736DC187CC
3 changed files with 106 additions and 0 deletions

7
.env Normal file
View File

@ -0,0 +1,7 @@
POSTGRES_USER=n8n
POSTGRES_PASSWORD=qsdqlijqsxiLIUNkihkqskd
POSTGRES_DB=n8n
POSTGRES_NON_ROOT_USER=n8n_non
POSTGRES_NON_ROOT_PASSWORD=Aqsdsdqisudlqisdulljlsjc
N8N_ENCRYPTION_KEY=;kjqhsds;fdsd!èç879

87
docker-compose.yml Normal file
View File

@ -0,0 +1,87 @@
version: '3.8'
services:
postgres:
image: postgres:16
restart: always
container_name: n8n_postgresql
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
networks:
- web
redis:
image: redis:6-alpine
restart: always
container_name: n8n_redis
volumes:
- redis_storage:/data
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
interval: 5s
timeout: 5s
retries: 10
networks:
- web
n8n:
restart: always
image: docker.n8n.io/n8nio/n8n:1.46.0
container_name: n8n
ports:
- "5678:5678"
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
- DB_POSTGRESDB_USER=${POSTGRES_NON_ROOT_USER}
- DB_POSTGRESDB_PASSWORD=${POSTGRES_NON_ROOT_PASSWORD}
- N8N_HOST=localhost
- N8N_PORT=5678
- N8N_PROTOCOL=http
- N8N_ENCRYPTION_KEY
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=user
- N8N_BASIC_AUTH_PASSWORD=password
- GENERIC_TIMEZONE=Europe/Paris
- NODE_ENV=production
- EXECUTIONS_MODE=regular
- QUEUE_BULL_REDIS_HOST=redis
- QUEUE_HEALTH_CHECK_ACTIVE=true
- WEBHOOK_URL=http://localhost
links:
- postgres
- redis
volumes:
- n8n_storage:/home/node/.n8n
depends_on:
redis:
condition: service_healthy
postgres:
condition: service_healthy
networks:
- web
- internet
volumes:
n8n_storage:
db_storage:
redis_storage:
networks:
web:
driver: bridge
internet:

12
init-data.sh Executable 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};
GRANT CREATE ON SCHEMA public TO ${POSTGRES_NON_ROOT_USER};
EOSQL
else
echo "SETUP INFO: No Environment variables given!"
fi