|
1 | | -# n8n |
2 | | -n8n allows you to build flexible workflows focused on deep data integration |
| 1 | +# NS8 n8n Module |
3 | 2 |
|
4 | | -## Install |
| 3 | +[](https://www.gnu.org/licenses/gpl-3.0) |
| 4 | +[](https://github.com/n8n-io/n8n) |
| 5 | + |
| 6 | +n8n allows you to build flexible workflows focused on deep data integration. This NS8 module provides a complete containerized deployment with PostgreSQL, Redis, and Traefik integration. |
| 7 | + |
| 8 | +## 🏗️ Architecture |
| 9 | + |
| 10 | +The module consists of multiple services orchestrated by systemd: |
| 11 | + |
| 12 | +- **n8n.service**: Main pod service that manages network connectivity |
| 13 | +- **n8n-pgsql.service**: PostgreSQL database (v15.5-bookworm) |
| 14 | +- **n8n-redis.service**: Redis cache (v7.2.3-bookworm) |
| 15 | +- **n8n-server.service**: n8n application server (v2.1.1) |
| 16 | + |
| 17 | +## 📦 Container Images |
| 18 | + |
| 19 | +The build process uses the following container images: |
| 20 | + |
| 21 | +- `docker.io/library/redis:7.2.3-bookworm` - Redis database |
| 22 | +- `docker.io/library/postgres:15.5-bookworm` - PostgreSQL database |
| 23 | +- `docker.io/n8nio/n8n:2.1.1` - n8n workflow automation |
| 24 | +- `docker.io/library/node:lts` - Node.js build environment |
| 25 | + |
| 26 | +## 🔧 Build Process |
| 27 | + |
| 28 | +The `build-images.sh` script creates the module image using Buildah: |
| 29 | + |
| 30 | +1. **UI Compilation**: Builds the Vue.js frontend with Node.js |
| 31 | +2. **Image Assembly**: Adds imageroot directory and compiled UI |
| 32 | +3. **Configuration**: Sets up entrypoint, labels, and container requirements |
| 33 | +4. **Publishing**: Pushes to GitHub Container Registry |
| 34 | + |
| 35 | +Key build features: |
| 36 | +- Reuses `nodebuilder-ns8-n8n` container for faster builds |
| 37 | +- Configures Traefik integration with route authorization |
| 38 | +- Sets rootless container with TCP port requirements |
| 39 | +- Supports CI/CD with GitHub Actions |
| 40 | + |
| 41 | +## 🚀 Installation |
5 | 42 |
|
6 | 43 | Instantiate the module with: |
7 | 44 |
|
8 | | - add-module ghcr.io/compgeniuses/n8n:latest 1 |
| 45 | +```bash |
| 46 | +add-module ghcr.io/geniusdynamics/n8n:latest 1 |
| 47 | +``` |
| 48 | + |
| 49 | +The output will return the instance name: |
| 50 | + |
| 51 | +```json |
| 52 | +{"module_id": "n8n", "image_name": "n8n", "image_url": "ghcr.io/geniusdynamics/n8n:latest"} |
| 53 | +``` |
| 54 | + |
| 55 | +## ⚙️ Configuration |
| 56 | + |
| 57 | +Assuming the n8n instance is named `n8n1`, configure with: |
| 58 | + |
| 59 | +```bash |
| 60 | +api-cli run module/n8n1/configure-module --data '{ |
| 61 | + "host": "n8n.domain.com", |
| 62 | + "lets_encrypt": false, |
| 63 | + "http2https": true |
| 64 | +}' |
| 65 | +``` |
| 66 | + |
| 67 | +### Configuration Parameters |
| 68 | + |
| 69 | +- `host`: Traefik host URL for the project |
| 70 | +- `lets_encrypt`: Enable/disable Let's Encrypt (default: false) |
| 71 | +- `http2https`: Enable HTTP to HTTPS redirect (default: true) |
9 | 72 |
|
10 | | -The output of the command will return the instance name. |
11 | | -Output example: |
| 73 | +## 🔍 Service Management |
12 | 74 |
|
13 | | - {"module_id": "n8n", "image_name": "n8n", "image_url": "ghcr.io/compgeniuses/n8n:latest"} |
| 75 | +### Systemd Services |
14 | 76 |
|
15 | | -## Configure |
| 77 | +All services are managed by systemd with the following characteristics: |
16 | 78 |
|
17 | | -Let's assume that the n8n instance is named `n8n1`. |
| 79 | +- **Restart Policy**: `always` for high availability |
| 80 | +- **Timeout**: 70 seconds for graceful shutdown |
| 81 | +- **Dependencies**: Proper service ordering (PostgreSQL → Redis → n8n) |
| 82 | +- **Health Checks**: Built-in container health monitoring |
18 | 83 |
|
19 | | -Launch `configure-module`, by setting the following parameters: |
| 84 | +### Service Dependencies |
20 | 85 |
|
| 86 | +``` |
| 87 | +n8n.service (pod) |
| 88 | +├── n8n-pgsql.service (database) |
| 89 | +├── n8n-redis.service (cache) |
| 90 | +└── n8n-server.service (application) |
| 91 | +``` |
21 | 92 |
|
22 | | -- `lets_encrypt`: Set LEtsecnrypt to True or False, Default is FALSE |
23 | | -- `http2https`: set redirect to True or False, Default is True |
24 | | -- `host`: the traefik host url for the project |
| 93 | +## 🌐 Network Configuration |
25 | 94 |
|
26 | | -- ... |
| 95 | +The module publishes the n8n web interface on: |
27 | 96 |
|
28 | | -Example: |
| 97 | +- **Internal**: Port 5678 within the pod |
| 98 | +- **External**: `127.0.0.1:${TCP_PORT}` via Traefik |
29 | 99 |
|
30 | | - api-cli run module/n8n1/configure-module --data '{"host": "n8n.domain.com"}' |
| 100 | +Test the service: |
31 | 101 |
|
32 | | - or if modifying another value: |
| 102 | +```bash |
| 103 | +curl http://127.0.0.1/n8n/ |
| 104 | +``` |
33 | 105 |
|
34 | | - api-cli run module/n8n5/configure-module --data '{"host": "n8n.domain.com","n8n_name": "Myn8n"}' |
| 106 | +## 🔄 Smarthost Integration |
35 | 107 |
|
36 | | - api-cli run module/n8n1/configure-module --data '{ |
37 | | - "host": "n8n.host.org", |
38 | | - "lets_encrypt": false, |
39 | | - "http2https": true, |
40 | | - }' |
| 108 | +The module automatically discovers smarthost settings from Redis: |
41 | 109 |
|
| 110 | +- `bin/discover-smarthost` refreshes `state/smarthost.env` |
| 111 | +- `events/smarthost-changed/10reload_services` handles configuration updates |
| 112 | +- Ensures email settings stay synchronized with NS8 core |
42 | 113 |
|
43 | | -The above command will: |
44 | | -- start and configure the n8n instance |
45 | | -- (describe configuration process) |
46 | | -- ... |
| 114 | +## 🧪 Testing |
47 | 115 |
|
| 116 | +Test the module using the provided test script: |
48 | 117 |
|
| 118 | +```bash |
| 119 | +./test-module.sh <NODE_ADDR> ghcr.io/geniusdynamics/n8n:latest |
| 120 | +``` |
49 | 121 |
|
50 | | -Send a test HTTP request to the ns8-n8n backend service: |
| 122 | +Tests are implemented using [Robot Framework](https://robotframework.org/). |
51 | 123 |
|
52 | | - curl http://127.0.0.1/n8n/ |
| 124 | +## 🌍 Internationalization |
53 | 125 |
|
54 | | -## Smarthost setting discovery |
| 126 | +The UI supports multiple languages through Weblate: |
55 | 127 |
|
56 | | -Some configuration settings, like the smarthost setup, are not part of the |
57 | | -`configure-module` action input: they are discovered by looking at some |
58 | | -Redis keys. To ensure the module is always up-to-date with the |
59 | | -centralized [smarthost |
60 | | -setup](https://nethserver.github.io/ns8-core/core/smarthost/) every time |
61 | | -kickstart starts, the command `bin/discover-smarthost` runs and refreshes |
62 | | -the `state/smarthost.env` file with fresh values from Redis. |
| 128 | +- **Supported Languages**: English, German, Spanish, Basque, Italian |
| 129 | +- **Translation Platform**: [Weblate](https://hosted.weblate.org/projects/ns8/) |
63 | 130 |
|
64 | | -Furthermore if smarthost setup is changed when ns8-n8n-ngx is already |
65 | | -running, the event handler `events/smarthost-changed/10reload_services` |
66 | | -restarts the main module service. |
| 131 | +To enable translation updates: |
| 132 | +1. Add [GitHub Weblate app](https://docs.weblate.org/en/latest/admin/continuous.html#github-setup) |
| 133 | +2. Request addition to NS8 Weblate project |
67 | 134 |
|
68 | | -See also the `systemd/user/n8n-server.service` file. |
| 135 | +## 🔄 Updates |
69 | 136 |
|
70 | | -This setting discovery is just an example to understand how the module is |
71 | | -expected to work: it can be rewritten or discarded completely. |
| 137 | +Update the module to the latest version: |
72 | 138 |
|
73 | | -## Uninstall |
| 139 | +```bash |
| 140 | +api-cli run update-module --data '{ |
| 141 | + "module_url": "ghcr.io/geniusdynamics/n8n:latest", |
| 142 | + "instances": ["n8n1"], |
| 143 | + "force": true |
| 144 | +}' |
| 145 | +``` |
74 | 146 |
|
75 | | -To uninstall the instance: |
| 147 | +## 🗑️ Uninstallation |
76 | 148 |
|
77 | | - remove-module --no-preserve n8n1 |
| 149 | +Remove the instance (data will be preserved unless `--no-preserve` is used): |
78 | 150 |
|
79 | | -## Testing |
| 151 | +```bash |
| 152 | +remove-module --no-preserve n8n1 |
| 153 | +``` |
80 | 154 |
|
81 | | -Test the module using the `test-module.sh` script: |
| 155 | +## 📁 Volume Storage |
82 | 156 |
|
| 157 | +The module uses persistent volumes for: |
83 | 158 |
|
84 | | - ./test-module.sh <NODE_ADDR> ghcr.io/compgeniuses/n8n:latest |
| 159 | +- `db_storage`: PostgreSQL data directory |
| 160 | +- `n8n-redis-data`: Redis data with AOF enabled |
| 161 | +- `n8n_data`: n8n user data and workflows |
85 | 162 |
|
86 | | -The tests are made using [Robot Framework](https://robotframework.org/) |
| 163 | +## 🔒 Security Features |
87 | 164 |
|
88 | | -## UI translation |
| 165 | +- **Rootless Containers**: All services run without root privileges |
| 166 | +- **Network Isolation**: Services communicate within a private pod |
| 167 | +- **Traefik Integration**: Secure HTTPS termination and routing |
| 168 | +- **Environment Files**: Sensitive configuration stored separately |
89 | 169 |
|
90 | | -Translated with [Weblate](https://hosted.weblate.org/projects/ns8/). |
| 170 | +## 📄 License |
91 | 171 |
|
92 | | -To setup the translation process: |
| 172 | +This module is licensed under GPL-3.0-or-later. See [LICENSE](LICENSE) for details. |
93 | 173 |
|
94 | | -- add [GitHub Weblate app](https://docs.weblate.org/en/latest/admin/continuous.html#github-setup) to your repository |
95 | | -- add your repository to [hosted.weblate.org]((https://hosted.weblate.org) or ask a NethServer developer to add it to ns8 Weblate project |
| 174 | +## 🤝 Contributing |
96 | 175 |
|
97 | | -## To Do |
| 176 | +Contributions are welcome! Please ensure all changes: |
| 177 | +- Follow the existing code style |
| 178 | +- Include appropriate tests |
| 179 | +- Update documentation as needed |
98 | 180 |
|
0 commit comments