From 581e029dcadda4d076fda89febaf2f048db512d9 Mon Sep 17 00:00:00 2001 From: usmannasir Date: Thu, 10 Apr 2025 02:21:43 +0500 Subject: [PATCH] n8n container deployment improvement --- plogical/DockerSites.py | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/plogical/DockerSites.py b/plogical/DockerSites.py index 3f5f8c37a..b058d2960 100644 --- a/plogical/DockerSites.py +++ b/plogical/DockerSites.py @@ -808,10 +808,7 @@ services: ProcessUtilities.executioner(command) # Generate encryption key - store in self.data for use in docker-compose - # Using base64 to ensure key is properly formatted - import base64 - raw_key = randomPassword.generate_pass(32) - encryption_key = base64.b64encode(raw_key.encode()).decode() + encryption_key = randomPassword.generate_pass(32) self.data['N8N_ENCRYPTION_KEY'] = encryption_key # Create necessary directories with proper ownership from the start @@ -843,8 +840,7 @@ services: "settings": { "instanceId": f"n8n_{randomPassword.generate_pass(12)}", "tunnelSubdomain": None, - "deployment": "default", - "encryptionKey": encryption_key # Add encryption key to settings as well + "deployment": "default" }, "versionNotifications": { "enabled": False, @@ -881,25 +877,6 @@ services: command = f"chmod 644 {gitignore_file}" ProcessUtilities.executioner(command) - # Write encryption key to debug file - debug_file = f"{base_dir}/.n8n/.n8n/encryption_key_debug" - - # Write to temp file first - temp_debug = f'/home/cyberpanel/{str(randint(1000, 9999))}-debug' - with open(temp_debug, 'w') as f: - f.write(f"Config file key: {encryption_key}\nEnvironment variable: {self.data['N8N_ENCRYPTION_KEY']}") - - # Set ownership and permissions on temp file - command = f"chown 1000:1000 {temp_debug}" - ProcessUtilities.executioner(command) - - command = f"chmod 600 {temp_debug}" - ProcessUtilities.executioner(command) - - # Move to final location - command = f"mv {temp_debug} {debug_file}" - ProcessUtilities.executioner(command) - # Final recursive permission setup command = f"chown -R 1000:1000 {base_dir}" ProcessUtilities.executioner(command) @@ -910,17 +887,10 @@ services: command = f"find {base_dir} -type f -exec chmod 644 {{}} \\;" ProcessUtilities.executioner(command) - # Special permission for config and debug files + # Special permission for config file command = f"chmod 600 {config_file}" ProcessUtilities.executioner(command) - command = f"chmod 600 {debug_file}" - ProcessUtilities.executioner(command) - - # Verify final permissions - command = f"ls -la {base_dir}/.n8n/.n8n/" - ProcessUtilities.outputExecutioner(command) - return True except BaseException as msg: @@ -1087,7 +1057,7 @@ services: - N8N_ENCRYPTION_KEY={self.data['N8N_ENCRYPTION_KEY']} - N8N_USER_FOLDER=/home/node/.n8n - GENERIC_TIMEZONE=UTC - - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true + - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false ports: - "{self.data['port']}:5678" volumes: