Skip to content

Commit 7c69885

Browse files
authored
Merge pull request #12 from geniusdynamics/dev
Update N8n to v2.1.1
2 parents b7166ce + 7b01609 commit 7c69885

File tree

8 files changed

+301
-135
lines changed

8 files changed

+301
-135
lines changed

README.md

Lines changed: 138 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,180 @@
1-
# n8n
2-
n8n allows you to build flexible workflows focused on deep data integration
1+
# NS8 n8n Module
32

4-
## Install
3+
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
4+
[![n8n Version](https://img.shields.io/badge/n8n-2.1.1-orange.svg)](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
542

643
Instantiate the module with:
744

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)
972

10-
The output of the command will return the instance name.
11-
Output example:
73+
## 🔍 Service Management
1274

13-
{"module_id": "n8n", "image_name": "n8n", "image_url": "ghcr.io/compgeniuses/n8n:latest"}
75+
### Systemd Services
1476

15-
## Configure
77+
All services are managed by systemd with the following characteristics:
1678

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
1883

19-
Launch `configure-module`, by setting the following parameters:
84+
### Service Dependencies
2085

86+
```
87+
n8n.service (pod)
88+
├── n8n-pgsql.service (database)
89+
├── n8n-redis.service (cache)
90+
└── n8n-server.service (application)
91+
```
2192

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
2594

26-
- ...
95+
The module publishes the n8n web interface on:
2796

28-
Example:
97+
- **Internal**: Port 5678 within the pod
98+
- **External**: `127.0.0.1:${TCP_PORT}` via Traefik
2999

30-
api-cli run module/n8n1/configure-module --data '{"host": "n8n.domain.com"}'
100+
Test the service:
31101

32-
or if modifying another value:
102+
```bash
103+
curl http://127.0.0.1/n8n/
104+
```
33105

34-
api-cli run module/n8n5/configure-module --data '{"host": "n8n.domain.com","n8n_name": "Myn8n"}'
106+
## 🔄 Smarthost Integration
35107

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:
41109

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
42113

43-
The above command will:
44-
- start and configure the n8n instance
45-
- (describe configuration process)
46-
- ...
114+
## 🧪 Testing
47115

116+
Test the module using the provided test script:
48117

118+
```bash
119+
./test-module.sh <NODE_ADDR> ghcr.io/geniusdynamics/n8n:latest
120+
```
49121

50-
Send a test HTTP request to the ns8-n8n backend service:
122+
Tests are implemented using [Robot Framework](https://robotframework.org/).
51123

52-
curl http://127.0.0.1/n8n/
124+
## 🌍 Internationalization
53125

54-
## Smarthost setting discovery
126+
The UI supports multiple languages through Weblate:
55127

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/)
63130

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
67134

68-
See also the `systemd/user/n8n-server.service` file.
135+
## 🔄 Updates
69136

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:
72138

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+
```
74146

75-
To uninstall the instance:
147+
## 🗑️ Uninstallation
76148

77-
remove-module --no-preserve n8n1
149+
Remove the instance (data will be preserved unless `--no-preserve` is used):
78150

79-
## Testing
151+
```bash
152+
remove-module --no-preserve n8n1
153+
```
80154

81-
Test the module using the `test-module.sh` script:
155+
## 📁 Volume Storage
82156

157+
The module uses persistent volumes for:
83158

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
85162

86-
The tests are made using [Robot Framework](https://robotframework.org/)
163+
## 🔒 Security Features
87164

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
89169

90-
Translated with [Weblate](https://hosted.weblate.org/projects/ns8/).
170+
## 📄 License
91171

92-
To setup the translation process:
172+
This module is licensed under GPL-3.0-or-later. See [LICENSE](LICENSE) for details.
93173

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
96175

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
98180

build-images.sh

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,37 @@ images=()
1414
repobase="${REPOBASE:-ghcr.io/geniusdynamics}"
1515
# Configure the image name
1616
reponame="n8n"
17-
N8N_VERSION="1.57.0"
17+
18+
N8N_VERSION="2.1.1"
19+
1820

1921
# Create a new empty container image
2022
container=$(buildah from scratch)
2123

2224
# Reuse existing nodebuilder-kickstart container, to speed up builds
2325
if ! buildah containers --format "{{.ContainerName}}" | grep -q nodebuilder-ns8-n8n; then
24-
echo "Pulling NodeJS runtime..."
25-
buildah from --name nodebuilder-ns8-n8n -v "${PWD}:/usr/src:Z" docker.io/library/node:lts
26+
echo "Pulling NodeJS runtime..."
27+
buildah from --name nodebuilder-ns8-n8n -v "${PWD}:/usr/src:Z" docker.io/library/node:lts
2628
fi
2729

2830
echo "Build static UI files with node..."
2931
buildah run \
30-
--workingdir=/usr/src/ui \
31-
--env="NODE_OPTIONS=--openssl-legacy-provider" \
32-
nodebuilder-ns8-n8n \
33-
sh -c "yarn install && yarn build"
32+
--workingdir=/usr/src/ui \
33+
--env="NODE_OPTIONS=--openssl-legacy-provider" \
34+
nodebuilder-ns8-n8n \
35+
sh -c "yarn install && yarn build"
3436

3537
# Add imageroot directory to the container image
3638
buildah add "${container}" imageroot /imageroot
3739
buildah add "${container}" ui/dist /ui
3840
# Setup the entrypoint, ask to reserve one TCP port with the label and set a rootless container
3941
buildah config --entrypoint=/ \
40-
--label="org.nethserver.authorizations=traefik@node:routeadm" \
41-
--label="org.nethserver.tcp-ports-demand=1" \
42-
--label="org.nethserver.rootfull=0" \
43-
--label="org.nethserver.images=docker.io/library/redis:7.2.3-bookworm docker.io/library/postgres:15.5-bookworm docker.io/n8nio/n8n:${N8N_VERSION}" \
44-
--label="org.nethserver.tcp-ports-demand=1" \
45-
"${container}"
42+
--label="org.nethserver.authorizations=traefik@node:routeadm" \
43+
--label="org.nethserver.tcp-ports-demand=1" \
44+
--label="org.nethserver.rootfull=0" \
45+
--label="org.nethserver.images=docker.io/library/redis:7.2.3-bookworm docker.io/library/postgres:15.5-bookworm docker.io/n8nio/n8n:${N8N_VERSION} docker.io/n8nio/runners:2.1.1" \
46+
--label="org.nethserver.tcp-ports-demand=1" \
47+
"${container}"
4648
# Commit the image
4749
buildah commit "${container}" "${repobase}/${reponame}"
4850

@@ -60,14 +62,14 @@ images+=("${repobase}/${reponame}")
6062
#
6163

6264
#
63-
# Setup CI when pushing to Github.
65+
# Setup CI when pushing to Github.
6466
# Warning! docker::// protocol expects lowercase letters (,,)
6567
if [[ -n "${CI}" ]]; then
66-
# Set output value for Github Actions
67-
printf "images=%s\n" "${images[*],,}" >> "${GITHUB_OUTPUT}"
68+
# Set output value for Github Actions
69+
printf "images=%s\n" "${images[*],,}" >>"${GITHUB_OUTPUT}"
6870
else
69-
# Just print info for manual push
70-
printf "Publish the images with:\n\n"
71-
for image in "${images[@],,}"; do printf " buildah push %s docker://%s:%s\n" "${image}" "${image}" "${IMAGETAG:-latest}" ; done
72-
printf "\n"
71+
# Just print info for manual push
72+
printf "Publish the images with:\n\n"
73+
for image in "${images[@],,}"; do printf " buildah push %s docker://%s:%s\n" "${image}" "${image}" "${IMAGETAG:-latest}"; done
74+
printf "\n"
7375
fi

0 commit comments

Comments
 (0)