n8n container deployment improvement

This commit is contained in:
usmannasir
2025-04-10 02:21:43 +05:00
parent 5e8874817b
commit 581e029dca

View File

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