I’m working on deploying N8N using a Jelastic JPS template and running into an issue with environment variable resolution. The DB_POSTGRESDB_HOST
variable needs to contain the IP address of my PostgreSQL database node, but Jelastic isn’t properly setting this value during deployment.
Here’s my current JPS configuration:
type: install
id: workflow-automation
version: 1.2
name: Workflow Engine Setup
globals:
db_username: workflow-${fn.random(999)}
db_password: ${fn.password}
secret_key: app${fn.password}
nodes:
- nodeType: nginx
displayName: Proxy Server
cloudlets: 12
nodeGroup: lb
- image: n8nio/n8n:latest
displayName: Workflow Engine
cloudlets: 12
nodeGroup: app
links: database:dblink
env:
N8N_BASIC_AUTH_ACTIVE: true
N8N_BASIC_AUTH_USER: ${globals.db_username}
N8N_BASIC_AUTH_PASSWORD: ${globals.db_password}
N8N_ENCRYPTION_KEY: ${globals.secret_key}
DB_TYPE: postgresdb
DB_POSTGRESDB_DATABASE: workflow
DB_POSTGRESDB_HOST: ${nodes.database[0].address}
DB_POSTGRESDB_PORT: 5432
DB_POSTGRESDB_USER: ${globals.db_username}
DB_POSTGRESDB_PASSWORD: ${globals.db_password}
- image: postgres:15.3
cloudlets: 12
nodeGroup: database
displayName: Database Server
env:
POSTGRES_USER: ${globals.db_username}
POSTGRES_PASSWORD: ${globals.db_password}
POSTGRES_DB: workflow
I’ve attempted different syntax variations:
DB_POSTGRESDB_HOST: ${nodes.database[0].address}
DB_POSTGRESDB_HOST: ${nodes.database.first.address}
DB_POSTGRESDB_HOST: ${nodes.database.master.address}
The core issue seems to be timing related. When the environment variables are being processed, the PostgreSQL container hasn’t been created yet, so there’s no IP address to reference. The variable only gets populated correctly when I manually set it through the Jelastic dashboard after deployment.
How can I ensure the database node IP gets properly assigned to this environment variable during the automated deployment process?