Service References
devhost supports late-binding/runtime service references using {{ services.<name>.<property> }} placeholders. This allows services to dynamically discover configuration from other services in the stack (such as auto-allocated ports or bind hosts) right before they are launched.
This is particularly useful in multi-service monorepos where databases or backend services run on dynamically allocated ports (port = "auto"), and consuming services need to discover those ports to establish a network connection.
Placeholders
Section titled “Placeholders”This applies to:
- String fields in service
commandarrays - Values in service
envmaps
Supported properties
Section titled “Supported properties”port- The resolved port number of the target service (e.g.,
{{ services.postgres.port }}). - If the referenced service does not have a port configured,
devhostwill raise a resolution error at startup.
- The resolved port number of the target service (e.g.,
host- The configured routing host of the target service, falling back to its bind host if no custom host is defined.
bindHost- The direct bind host of the target service.
Example
Section titled “Example”[services.postgres]bindHost = "127.0.0.1"port = "auto"
[services.poc-backend]command = ["node", "server.js"]health = { tcp = 8080 }env = { DATABASE_URL = "postgres://postgres:postgres@{{ services.postgres.bindHost }}:{{ services.postgres.port }}/postgres?sslmode=disable" }In this example, both the bindHost and the dynamic port of the postgres database service are automatically resolved and injected into the backend’s DATABASE_URL environment variable at startup, with zero manual coordination or hardcoded ports.