oharu121 commited on
Commit
251322f
·
1 Parent(s): 2c9dde0

Automated n8n version updates

Browse files
Files changed (5) hide show
  1. .dev-notes/2026-01-14.md +39 -0
  2. .plans/auto-update-n8n.md +151 -0
  3. CHANGELOG.md +20 -0
  4. Dockerfile +62 -45
  5. renovate.json +29 -0
.dev-notes/2026-01-14.md ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## 📝 Dev Note: High-Volume Request Optimization
2
+
3
+ **Date:** 2026-01-14
4
+
5
+ **Author:** Yuchen (Jeff) Lin
6
+
7
+ **Context:** Article View Boosting Logic (2,200+ Requests)
8
+
9
+ ### 🔴 Identified Issues
10
+
11
+ 1. **Database Connection Timeout:** n8n's visual loops triggered 6,000+ DB writes (Supabase), locking the instance and making the UI inaccessible.
12
+ 2. **PayloadTooLargeError:** Passing an array of 2,000+ objects between nodes exceeded n8n's internal JSON memory limits.
13
+ 3. **Task Runner Timeout:** The default 300s (5-minute) limit was insufficient for a sequential 2,000-request loop with a 300ms delay (~10+ minutes).
14
+
15
+ ### 🟢 Solutions Implemented
16
+
17
+ #### 1. Infrastructure (Dockerfile)
18
+
19
+ * **Timeout Extension:** Increased `N8N_RUNNERS_TASK_TIMEOUT` to `900` to allow 15-minute executions.
20
+ * **Execution Pruning:** Set `EXECUTIONS_DATA_SAVE_ON_SUCCESS=none` to minimize Supabase storage/IOPS usage.
21
+ * **Resource Management:** Limited `N8N_CONCURRENCY_PRODUCTION_LIMIT` to `10` to stay within HF Spaces free tier (2 vCPU).
22
+
23
+ #### 2. Logic (Code Node Modular Batching)
24
+
25
+ * **Consolidation:** Merged UA generation and HTTP logic into a single Code Node to reduce n8n overhead to **one single DB write** per channel.
26
+ * **Parallel Chunking:** Implemented a "Batch of 5" approach.
27
+ * **Logic:** Processes 5 parallel requests via `Promise.all()`, then waits 300ms.
28
+ * **Result:** Reduced total execution time by ~80% while respecting target site rate limits.
29
+
30
+
31
+ * **Native Fetch:** Used Node 24 global `fetch` and `AbortSignal.timeout(5000)` to prevent "hanging" processes.
32
+
33
+ ---
34
+
35
+ ### ⚠️ Maintenance Warnings
36
+
37
+ * **Memory Usage:** If increasing `totalRequests` beyond 5,000, monitor HF Space RAM (16GB). The `allUAs` array is stored in memory.
38
+ * **Supabase Pool:** If the DB times out again, check `DB_POSTGRESDB_POOL_MAX_SIZE`. It is currently set to `5` to prevent exhausting Supabase free-tier connections.
39
+ * **Node Selection:** Always ensure the Code Node is in **"Run once for all items"** mode.
.plans/auto-update-n8n.md ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Plan: Auto-Detect and Deploy New n8n Versions
2
+
3
+ ## Current State Analysis
4
+
5
+ Your n8n deployment has:
6
+ - **Dockerfile** at `Dockerfile` - installs n8n via `npm install -g n8n` (no version pinning)
7
+ - **GitHub Actions** at `.github/workflows/deploy-to-hf-spaces.yml` - deploys to Hugging Face Spaces on push to main
8
+ - **No automated version checking** currently exists
9
+
10
+ ### Key Finding
11
+ Your current setup already uses the latest n8n version on each rebuild, but rebuilds only happen on manual pushes. There's no proactive detection of new releases.
12
+
13
+ ---
14
+
15
+ ## Recommended Approach: Renovate Bot
16
+
17
+ **Why Renovate over alternatives:**
18
+ | Option | Pros | Cons |
19
+ |--------|------|------|
20
+ | **Renovate** | Industry standard, regex manager for Dockerfile npm packages, auto-merge capable, PR-based (reviewable) | Requires initial setup |
21
+ | Dependabot | Built into GitHub | Cannot detect npm packages in Dockerfiles |
22
+ | Watchtower | Zero config for Docker | Bypasses CI/CD, no review process |
23
+ | Custom GitHub Action | Full control | Maintenance burden |
24
+
25
+ ---
26
+
27
+ ## Implementation Plan
28
+
29
+ ### Step 1: Pin n8n Version in Dockerfile
30
+ Modify `Dockerfile` to use explicit version:
31
+ ```dockerfile
32
+ # Change from:
33
+ RUN npm install -g n8n
34
+ # To:
35
+ ARG N8N_VERSION=1.73.1
36
+ RUN npm install -g n8n@${N8N_VERSION}
37
+ ```
38
+
39
+ ### Step 2: Add Renovate Configuration
40
+ Create `renovate.json` in repository root:
41
+ ```json
42
+ {
43
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
44
+ "extends": ["config:recommended"],
45
+ "customManagers": [
46
+ {
47
+ "customType": "regex",
48
+ "fileMatch": ["^Dockerfile$"],
49
+ "matchStrings": ["ARG N8N_VERSION=(?<currentValue>.*?)\\n"],
50
+ "depNameTemplate": "n8n",
51
+ "datasourceTemplate": "npm"
52
+ }
53
+ ],
54
+ "packageRules": [
55
+ {
56
+ "matchPackageNames": ["n8n"],
57
+ "automerge": true,
58
+ "automergeType": "pr",
59
+ "schedule": ["every weekend"],
60
+ "prPriority": 10,
61
+ "platformAutomerge": true
62
+ },
63
+ {
64
+ "matchPackageNames": ["n8n"],
65
+ "matchUpdateTypes": ["major"],
66
+ "automerge": false,
67
+ "labels": ["breaking-change"]
68
+ }
69
+ ]
70
+ }
71
+ ```
72
+
73
+ **Note**: Major version updates (e.g., 1.x → 2.x) will NOT auto-merge due to potential breaking changes. You'll need to review these manually.
74
+
75
+ ### Step 3: Enable Renovate GitHub App
76
+ 1. Install Renovate from GitHub Marketplace (free for public repos)
77
+ 2. Grant access to this repository
78
+ 3. Renovate will auto-create an onboarding PR
79
+
80
+ ### Step 4: Auto-Deploy on Merge
81
+ Your existing workflow already triggers on push to main, so when Renovate auto-merges a PR, it will automatically deploy to HF Spaces.
82
+
83
+ **End-to-end flow**: Renovate detects update → Creates PR → Auto-merges (weekends) → GitHub Actions deploys → n8n updated
84
+
85
+ ---
86
+
87
+ ## Files to Create/Modify
88
+
89
+ | File | Action | Purpose |
90
+ |------|--------|---------|
91
+ | `Dockerfile` | **Modify** | Add `ARG N8N_VERSION=x.x.x` and use it in npm install |
92
+ | `renovate.json` | **Create** | Configure Renovate to detect n8n version |
93
+
94
+ ---
95
+
96
+ ## How It Works (Flow)
97
+
98
+ ```
99
+ Renovate checks npm registry (scheduled)
100
+
101
+
102
+ New n8n version detected
103
+
104
+
105
+ PR created: "Update n8n to x.x.x"
106
+
107
+
108
+ Auto-merged (weekends) or manual review (major versions)
109
+
110
+
111
+ GitHub Actions deploys to HF Spaces
112
+
113
+
114
+ n8n updated in production
115
+ ```
116
+
117
+ ---
118
+
119
+ ## Safety Considerations
120
+
121
+ 1. **Major version protection**: The config blocks auto-merge for major updates (1.x → 2.x). Use n8n's [Migration Report tool](https://blog.n8n.io/introducing-n8n-2-0/) before manually merging these.
122
+
123
+ 2. **Your settings**:
124
+ - Auto-merge: ✅ Enabled for patch AND minor updates
125
+ - Schedule: Weekends only
126
+ - Manual review: Required for major version updates only
127
+
128
+ 3. **Rollback**: If an update breaks workflows:
129
+ - Revert the Renovate PR commit in GitHub
130
+ - Push reverts to trigger redeployment
131
+
132
+ 4. **Monitoring**: Watch the Renovate dashboard issue for update status and any failed merges
133
+
134
+ ---
135
+
136
+ ## Verification
137
+
138
+ After implementation:
139
+ 1. Check Renovate dashboard issue in GitHub for detected dependencies
140
+ 2. Wait for scheduled run or trigger manually via dashboard
141
+ 3. Review the auto-created PR for n8n update
142
+ 4. Merge and verify HF Spaces deployment succeeds
143
+ 5. Test critical workflows in n8n
144
+
145
+ ---
146
+
147
+ ## Sources
148
+ - [Renovate Regex Manager Docs](https://docs.renovatebot.com/modules/manager/regex/)
149
+ - [n8n 2.0 Migration Guide](https://blog.n8n.io/introducing-n8n-2-0/)
150
+ - [n8n Release Notes](https://docs.n8n.io/release-notes/)
151
+ - [Renovate vs Dependabot Comparison](https://www.turbostarter.dev/blog/renovate-vs-dependabot-whats-the-best-tool-to-automate-your-dependency-updates)
CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
 
3
  All notable changes to this project will be documented in this file.
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  ## [1.1.0] - 2026-01-12
6
 
7
  ### Fixed
 
2
 
3
  All notable changes to this project will be documented in this file.
4
 
5
+ ## [1.2.0] - 2026-01-15
6
+
7
+ ### Added
8
+ - **Automated n8n version updates** - Integrated Renovate Bot for automatic detection and deployment of new n8n releases
9
+ - `renovate.json` - Configuration for Renovate to monitor n8n versions in Dockerfile
10
+ - Version pinning in Dockerfile (`ARG N8N_VERSION=2.3.4`)
11
+
12
+ ### Changed
13
+ - n8n installation now uses explicit version (`npm install -g n8n@${N8N_VERSION}`) instead of latest
14
+
15
+ ### How It Works
16
+ - Renovate checks npm registry every weekend for new n8n versions
17
+ - Patch and minor updates auto-merge and deploy via existing GitHub Actions
18
+ - Major version updates require manual review (labeled `breaking-change`)
19
+
20
+ ### Required Manual Steps
21
+ 1. Install Renovate GitHub App: https://github.com/apps/renovate
22
+ 2. Grant access to this repository
23
+ 3. Merge the onboarding PR that Renovate creates
24
+
25
  ## [1.1.0] - 2026-01-12
26
 
27
  ### Fixed
Dockerfile CHANGED
@@ -36,8 +36,9 @@ RUN cp /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
36
  # Create app directory
37
  WORKDIR /home/node/app
38
 
39
- # Install n8n globally (latest stable)
40
- RUN npm install -g n8n
 
41
 
42
  # Copy scripts
43
  COPY scripts/startup.sh /home/node/app/startup.sh
@@ -48,37 +49,37 @@ RUN chmod +x /home/node/app/*.sh
48
  # Environment Configuration
49
  # =============================================================================
50
 
51
- # n8n Core Settings - Port 7860 is REQUIRED by HF Spaces
 
 
 
52
  ENV N8N_PORT=7860
53
  ENV N8N_PROTOCOL=https
54
  ENV N8N_HOST=0.0.0.0
55
- ENV NODE_ENV=production
56
-
57
- # Health & Metrics (required for wake-up endpoint)
58
- ENV QUEUE_HEALTH_CHECK_ACTIVE=true
59
- ENV N8N_METRICS=true
60
-
61
- # Timezone for scheduled workflows
62
- ENV GENERIC_TIMEZONE=Asia/Tokyo
63
-
64
- # Disable secure cookie - HF Spaces handles HTTPS termination
65
  ENV N8N_SECURE_COOKIE=false
66
-
67
- # Trust proxy headers from HF Spaces reverse proxy (fixes rate-limit validation errors)
68
  ENV N8N_TRUST_PROXY=true
69
-
70
- # Chromium for puppeteer-based nodes
71
- ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
72
- ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
73
-
74
- # n8n data directory - use /data for HF persistent storage
75
  ENV N8N_USER_FOLDER=/data/.n8n
76
 
77
- # Database Optimization for Supabase / Remote Postgres
 
 
 
 
 
 
 
 
78
  ENV DB_POSTGRESDB_TIMEOUT=60000
79
  ENV DB_POSTGRESDB_POOL_MAX_SIZE=5
80
  ENV DB_POSTGRESDB_POOL_IDLE_TIMEOUT=20000
81
 
 
 
 
 
 
 
 
82
  # Execution data pruning (prevents Supabase free tier from filling up)
83
  ENV EXECUTIONS_DATA_PRUNE=true
84
  ENV EXECUTIONS_DATA_MAX_AGE=168
@@ -86,37 +87,53 @@ ENV EXECUTIONS_DATA_SAVE_ON_SUCCESS=none
86
  ENV EXECUTIONS_DATA_SAVE_ON_PROGRESS=false
87
  ENV EXECUTIONS_DATA_SAVE_ON_ERROR=all
88
 
89
- # Production logging (reduce noise)
90
- ENV N8N_LOG_LEVEL=warn
 
 
 
91
 
92
- # Limit concurrent executions (prevents resource exhaustion)
93
- ENV N8N_CONCURRENCY_PRODUCTION_LIMIT=10
 
 
 
94
 
95
- # Disable telemetry (optional)
 
 
 
 
96
  ENV N8N_DIAGNOSTICS_ENABLED=false
 
97
 
98
- # Enbale modules import for js code node
99
- ENV NODE_FUNCTION_ALLOW_EXTERNAL=node-fetch
100
- ENV NODE_FUNCTION_ALLOW_BUILTIN=node:timers/promises
101
-
102
- ENV N8N_RUNNERS_TASK_TIMEOUT=900
103
 
104
  # =============================================================================
105
  # Runtime Secrets (set via HF Spaces Settings > Variables and Secrets)
106
  # =============================================================================
107
- # N8N_ENCRYPTION_KEY - Encryption key for credentials
108
- # N8N_BASIC_AUTH_ACTIVE - Set to "true" to enable basic auth
109
- # N8N_BASIC_AUTH_USER - Username for basic auth
110
- # N8N_BASIC_AUTH_PASSWORD - Password for basic auth
111
- # WEBHOOK_URL - https://oharu121-n8n-workflow.hf.space
112
- # N8N_EDITOR_BASE_URL - https://oharu121-n8n-workflow.hf.space
113
- # DB_TYPE - postgresdb
114
- # DB_POSTGRESDB_HOST - Supabase host
115
- # DB_POSTGRESDB_PORT - 5432 (session mode - required for n8n)
116
- # DB_POSTGRESDB_DATABASE - postgres
117
- # DB_POSTGRESDB_USER - postgres
118
- # DB_POSTGRESDB_PASSWORD - Supabase password
119
- # DB_POSTGRESDB_SSL_ENABLED - true
 
 
 
 
 
120
 
121
  # Expose port 7860 (required by HF Spaces)
122
  EXPOSE 7860
 
36
  # Create app directory
37
  WORKDIR /home/node/app
38
 
39
+ # Install n8n globally (version managed by Renovate)
40
+ ARG N8N_VERSION=2.3.4
41
+ RUN npm install -g n8n@${N8N_VERSION}
42
 
43
  # Copy scripts
44
  COPY scripts/startup.sh /home/node/app/startup.sh
 
49
  # Environment Configuration
50
  # =============================================================================
51
 
52
+ # -----------------------------------------------------------------------------
53
+ # Core Server Settings (HF Spaces requirements)
54
+ # -----------------------------------------------------------------------------
55
+ ENV NODE_ENV=production
56
  ENV N8N_PORT=7860
57
  ENV N8N_PROTOCOL=https
58
  ENV N8N_HOST=0.0.0.0
 
 
 
 
 
 
 
 
 
 
59
  ENV N8N_SECURE_COOKIE=false
 
 
60
  ENV N8N_TRUST_PROXY=true
 
 
 
 
 
 
61
  ENV N8N_USER_FOLDER=/data/.n8n
62
 
63
+ # -----------------------------------------------------------------------------
64
+ # Timezone
65
+ # -----------------------------------------------------------------------------
66
+ ENV GENERIC_TIMEZONE=Asia/Tokyo
67
+
68
+ # -----------------------------------------------------------------------------
69
+ # Database Configuration (Supabase PostgreSQL)
70
+ # -----------------------------------------------------------------------------
71
+ ENV DB_POSTGRESDB_SCHEMA=public
72
  ENV DB_POSTGRESDB_TIMEOUT=60000
73
  ENV DB_POSTGRESDB_POOL_MAX_SIZE=5
74
  ENV DB_POSTGRESDB_POOL_IDLE_TIMEOUT=20000
75
 
76
+ # -----------------------------------------------------------------------------
77
+ # Execution & Performance
78
+ # -----------------------------------------------------------------------------
79
+ ENV N8N_CONCURRENCY_PRODUCTION_LIMIT=10
80
+ ENV N8N_RUNNERS_ENABLED=true
81
+ ENV N8N_RUNNERS_TASK_TIMEOUT=900
82
+
83
  # Execution data pruning (prevents Supabase free tier from filling up)
84
  ENV EXECUTIONS_DATA_PRUNE=true
85
  ENV EXECUTIONS_DATA_MAX_AGE=168
 
87
  ENV EXECUTIONS_DATA_SAVE_ON_PROGRESS=false
88
  ENV EXECUTIONS_DATA_SAVE_ON_ERROR=all
89
 
90
+ # -----------------------------------------------------------------------------
91
+ # Code Node Settings
92
+ # -----------------------------------------------------------------------------
93
+ ENV NODE_FUNCTION_ALLOW_EXTERNAL=node-fetch
94
+ ENV NODE_FUNCTION_ALLOW_BUILTIN=*
95
 
96
+ # -----------------------------------------------------------------------------
97
+ # External Tools (Puppeteer/Chromium)
98
+ # -----------------------------------------------------------------------------
99
+ ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
100
+ ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
101
 
102
+ # -----------------------------------------------------------------------------
103
+ # Monitoring & Logging
104
+ # -----------------------------------------------------------------------------
105
+ ENV N8N_LOG_LEVEL=warn
106
+ ENV N8N_METRICS=true
107
  ENV N8N_DIAGNOSTICS_ENABLED=false
108
+ ENV QUEUE_HEALTH_CHECK_ACTIVE=true
109
 
110
+ # -----------------------------------------------------------------------------
111
+ # Feature Flags & Integrations
112
+ # -----------------------------------------------------------------------------
113
+ ENV N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
114
+ ENV NOTION_MARKDOWN_CONVERSION=true
115
 
116
  # =============================================================================
117
  # Runtime Secrets (set via HF Spaces Settings > Variables and Secrets)
118
  # =============================================================================
119
+ # Authentication:
120
+ # N8N_ENCRYPTION_KEY - Encryption key for credentials
121
+ # N8N_BASIC_AUTH_ACTIVE - Set to "true" to enable basic auth
122
+ # N8N_BASIC_AUTH_USER - Username for basic auth
123
+ # N8N_BASIC_AUTH_PASSWORD - Password for basic auth
124
+ #
125
+ # URLs:
126
+ # WEBHOOK_URL - https://your-space.hf.space
127
+ # N8N_EDITOR_BASE_URL - https://your-space.hf.space
128
+ #
129
+ # Database:
130
+ # DB_TYPE - postgresdb
131
+ # DB_POSTGRESDB_HOST - Supabase host
132
+ # DB_POSTGRESDB_PORT - 5432 (session mode - required for n8n)
133
+ # DB_POSTGRESDB_DATABASE - postgres
134
+ # DB_POSTGRESDB_USER - postgres.your-project-ref
135
+ # DB_POSTGRESDB_PASSWORD - Supabase password
136
+ # DB_POSTGRESDB_SSL_ENABLED - true
137
 
138
  # Expose port 7860 (required by HF Spaces)
139
  EXPOSE 7860
renovate.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": ["config:recommended"],
4
+ "customManagers": [
5
+ {
6
+ "customType": "regex",
7
+ "fileMatch": ["^Dockerfile$"],
8
+ "matchStrings": ["ARG N8N_VERSION=(?<currentValue>.*?)\\n"],
9
+ "depNameTemplate": "n8n",
10
+ "datasourceTemplate": "npm"
11
+ }
12
+ ],
13
+ "packageRules": [
14
+ {
15
+ "matchPackageNames": ["n8n"],
16
+ "automerge": true,
17
+ "automergeType": "pr",
18
+ "schedule": ["every weekend"],
19
+ "prPriority": 10,
20
+ "platformAutomerge": true
21
+ },
22
+ {
23
+ "matchPackageNames": ["n8n"],
24
+ "matchUpdateTypes": ["major"],
25
+ "automerge": false,
26
+ "labels": ["breaking-change"]
27
+ }
28
+ ]
29
+ }