Initial commit to release
This commit is contained in:
6
docker/compose/withMongo/.env
Normal file
6
docker/compose/withMongo/.env
Normal file
@@ -0,0 +1,6 @@
|
||||
MONGO_INITDB_ROOT_USERNAME=adminuser
|
||||
MONGO_INITDB_ROOT_PASSWORD=JvsjjAYg12FJ90sdCBdsh322V
|
||||
MONGO_INITDB_DATABASE=n8n
|
||||
|
||||
MONGO_NON_ROOT_USERNAME=n8nuser
|
||||
MONGO_NON_ROOT_PASSWORD=PLsQ8vHGShwDFdmSssb
|
||||
26
docker/compose/withMongo/README.md
Normal file
26
docker/compose/withMongo/README.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# n8n with MongoDB
|
||||
|
||||
Starts n8n with MongoDB as database.
|
||||
|
||||
|
||||
## Start
|
||||
|
||||
To start n8n with MongoDB simply start docker-compose by executing the following
|
||||
command in the current folder.
|
||||
|
||||
|
||||
**IMPORTANT:** But before you do that change the default users and passwords in the `.env` file!
|
||||
|
||||
```
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
To stop it execute:
|
||||
|
||||
```
|
||||
docker-compose stop
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
The default name of the database, user and password for MongoDB can be changed in the `.env` file in the current directory.
|
||||
28
docker/compose/withMongo/docker-compose.yml
Normal file
28
docker/compose/withMongo/docker-compose.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
version: '3.1'
|
||||
|
||||
services:
|
||||
|
||||
mongo:
|
||||
image: mongo:4.0
|
||||
restart: always
|
||||
environment:
|
||||
- MONGO_INITDB_ROOT_USERNAME
|
||||
- MONGO_INITDB_ROOT_PASSWORD
|
||||
- MONGO_INITDB_DATABASE
|
||||
- MONGO_NON_ROOT_USERNAME
|
||||
- MONGO_NON_ROOT_PASSWORD
|
||||
volumes:
|
||||
- ./init-data.sh:/docker-entrypoint-initdb.d/init-data.sh
|
||||
|
||||
n8n:
|
||||
image: n8n
|
||||
restart: always
|
||||
ports:
|
||||
- 5678:5678
|
||||
links:
|
||||
- mongo
|
||||
volumes:
|
||||
- ~/.n8n:/root/.n8n
|
||||
# Wait 5 seconds to start n8n to make sure that MongoDB is ready
|
||||
# when n8n tries to connect to it
|
||||
command: /bin/sh -c "sleep 5; n8n start --NODE_CONFIG='{\"database\":{\"type\":\"mongodb\", \"mongodbConfig\":{\"url\":\"mongodb://n8nuser:${MONGO_NON_ROOT_PASSWORD}@mongo:27017/${MONGO_INITDB_DATABASE}\"}}}'"
|
||||
17
docker/compose/withMongo/init-data.sh
Executable file
17
docker/compose/withMongo/init-data.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
set -e;
|
||||
|
||||
# Create a default non-root role
|
||||
MONGO_NON_ROOT_ROLE="${MONGO_NON_ROOT_ROLE:-readWrite}"
|
||||
|
||||
if [ -n "${MONGO_NON_ROOT_USERNAME:-}" ] && [ -n "${MONGO_NON_ROOT_PASSWORD:-}" ]; then
|
||||
"${mongo[@]}" "$MONGO_INITDB_DATABASE" <<-EOJS
|
||||
db.createUser({
|
||||
user: $(_js_escape "$MONGO_NON_ROOT_USERNAME"),
|
||||
pwd: $(_js_escape "$MONGO_NON_ROOT_PASSWORD"),
|
||||
roles: [ { role: $(_js_escape "$MONGO_NON_ROOT_ROLE"), db: $(_js_escape "$MONGO_INITDB_DATABASE") } ]
|
||||
})
|
||||
EOJS
|
||||
else
|
||||
echo "SETUP INFO: No Environment variables given!"
|
||||
fi
|
||||
18
docker/images/n8n/Dockerfile
Normal file
18
docker/images/n8n/Dockerfile
Normal file
@@ -0,0 +1,18 @@
|
||||
FROM mhart/alpine-node:10
|
||||
|
||||
# Update everything and install needed dependencies
|
||||
RUN apk add --update \
|
||||
graphicsmagick
|
||||
|
||||
# # Set a custom user to not have n8n run as root
|
||||
USER root
|
||||
|
||||
# Install n8n and the also temporary all the packages
|
||||
# it needs to build it correctly.
|
||||
RUN apk --update add --virtual build-dependencies python build-base && \
|
||||
npm_config_user=root npm install -g n8n && \
|
||||
apk del build-dependencies
|
||||
|
||||
WORKDIR /data
|
||||
|
||||
CMD "n8n"
|
||||
84
docker/images/n8n/README.md
Normal file
84
docker/images/n8n/README.md
Normal file
@@ -0,0 +1,84 @@
|
||||
## n8n
|
||||
|
||||

|
||||
|
||||
Run n8n in Docker.
|
||||
|
||||
```
|
||||
docker run -it --rm \
|
||||
--name n8n \
|
||||
-p 5678:5678 \
|
||||
n8nio/n8n
|
||||
```
|
||||
|
||||
You can then access n8n by opening:
|
||||
[http://localhost:5678](http://localhost:5678)
|
||||
|
||||
|
||||
## Start with tunnel
|
||||
|
||||
To be able to use webhooks which all triggers of external services like Github
|
||||
rely on n8n has to be reachable from the web. To make that easy n8n has a
|
||||
special tunnel service which redirects requests from our servers to your local
|
||||
n8n instance.
|
||||
|
||||
To use it simply start n8n with `--tunnel`
|
||||
|
||||
```
|
||||
docker run -it --rm \
|
||||
--name n8n \
|
||||
--init \
|
||||
-p 5678:5678 \
|
||||
-v ~/.n8n:/root/.n8n \
|
||||
n8nio/n8n \
|
||||
n8n start --tunnel
|
||||
```
|
||||
|
||||
## Persist data
|
||||
|
||||
The workflow data gets by default saved in an SQLite database in the user
|
||||
folder (`/root/.n8n`). That folder also additionally contains the
|
||||
settings like webhook URL and encryption key.
|
||||
|
||||
```
|
||||
docker run -it --rm \
|
||||
--name n8n \
|
||||
-p 5678:5678 \
|
||||
-v ~/.n8n:/root/.n8n \
|
||||
n8nio/n8n
|
||||
```
|
||||
|
||||
## Use with MongoDB
|
||||
|
||||
Instead of SQLite, it is also possible to run n8n with MongoDB.
|
||||
|
||||
It is important to still persist the data in the `/root/.n8` folder. The reason
|
||||
is that it contains n8n user data. That is the name of the webhook
|
||||
(in case) the n8n tunnel gets used and even more important the encryption key
|
||||
for the credentials. If none gets found n8n creates automatically one on
|
||||
startup. In case credentials are already saved with a different encryption key
|
||||
it can not be used anymore as encrypting it is not possible anymore.
|
||||
|
||||
Replace the following placeholders with the actual data:
|
||||
- MONGO_DATABASE
|
||||
- MONGO_HOST
|
||||
- MONGO_PORT
|
||||
- MONGO_USER
|
||||
- MONGO_PASSWORD
|
||||
|
||||
```
|
||||
docker run -it --rm \
|
||||
--name n8n \
|
||||
-p 5678:5678 \
|
||||
-v ~/.n8n:/root/.n8n \
|
||||
n8nio/n8n \
|
||||
n8n start \
|
||||
--NODE_CONFIG='{\"database\":{\"type\":\"mongodb\", \"mongodbConfig\":{\"url\":\"mongodb://MONGO_USER:MONGO_PASSWORD@MONGO_SERVER:MONGO_PORT/MONGO_DATABASE\"}}}'"
|
||||
```
|
||||
|
||||
A full working setup with docker-compose can be found [here](../../compose/withMongo/README.md)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
n8n is licensed under **Apache 2.0 with Commons Clause**
|
||||
Reference in New Issue
Block a user