Deploy with a reference
The variable keeps a reference. Each container gets the real database URL when it starts.
Run this command from the notes directory.
Terminal
$ ferry up notes -e 'DATABASE_URL=${{datastore.notes-db.connectionString}}' --follow==> Detected Node.js runtime==> Generated Dockerfile.ferry for the Node.js runtime#8 [stage-0 4/5] RUN --mount=type=secret,id=DATABASE_URL,env=DATABASE_URL npm install --include=dev --no-audit --no-fund#8 1.014 added 14 packages in 863ms==> Build successful 🎉==> Using port 10000 (default port)==> Limits: 512 MiB memory, 1 CPU per instance…==> Your service is live 🎉==> Available at http://notes.localhost:8080What the reference does
${{datastore.notes-db.connectionString}} is a reference. The variable keeps the reference as you wrote it. Each container gets the real URL when it starts. The URL uses the private network: notes-db:5432.
| Part | Meaning |
|---|---|
datastore | The kind of thing |
notes-db | The name of the datastore |
connectionString | The property: the internal URL |
The Env var references page lists all the properties.
Keep the single quotes
Without the single quotes, your shell changes the text of the reference before ferry gets it.