I’m having trouble setting up N8N using a Jelastic JPS configuration file. The main issue is that the environment variable for the database host isn’t getting the correct PostgreSQL IP address.
I need to pass the PostgreSQL node’s IP to the DB_POSTGRESDB_HOST variable using something like ${nodes.database[0].address}. When I manually set this variable through the web interface it works fine, but it doesn’t work when defined in the JPS file.
type: install
name: N8N Automation Tool
version: 1.1
id: n8n-deploy
homepage: https://n8n.io/
globals:
app_user: automation-${fn.random(999)}
app_pass: ${fn.password}
secret_key: app${fn.password}
nodes:
- nodeType: nginx
displayName: Proxy Server
cloudlets: 8
nodeGroup: proxy
- image: n8nio/n8n:latest
displayName: N8N App
cloudlets: 12
nodeGroup: app
env:
N8N_BASIC_AUTH_ACTIVE: true
N8N_BASIC_AUTH_USER: ${globals.app_user}
N8N_BASIC_AUTH_PASSWORD: ${globals.app_pass}
N8N_ENCRYPTION_KEY: ${globals.secret_key}
DB_TYPE: postgresdb
DB_POSTGRESDB_DATABASE: automation
DB_POSTGRESDB_HOST: ${nodes.database[0].address}
DB_POSTGRESDB_PORT: 5432
DB_POSTGRESDB_USER: ${globals.app_user}
DB_POSTGRESDB_PASSWORD: ${globals.app_pass}
- image: postgres:15
cloudlets: 8
nodeGroup: database
displayName: Database Server
env:
POSTGRES_USER: ${globals.app_user}
POSTGRES_PASSWORD: ${globals.app_pass}
POSTGRES_DB: automation
I’ve tried different ways to reference the database IP:
DB_POSTGRESDB_HOST: ${nodes.database[0].address}
DB_POSTGRESDB_HOST: ${nodes.database.first.address}
DB_POSTGRESDB_HOST: ${nodes.database.master.address}
I think the issue is timing related. The database node doesn’t have an IP yet when the environment variables are being set. How can I assign the IP address after the PostgreSQL container is created and running?
Any ideas on how to solve this?