Developer Documentation

Connecting Services to Each Other

Services, depending on the type and attributes, export environment variables that you can import within the env configuration of another service.

The name of the exported variable follows the ${SERVICE_NAME}_${ATTRIBUTE} pattern. Dashes -, in the service name, are converted to underscores _ and the exported environment variable name is always uppercase.

If your config includes service names that are too similar, like blog-1 and blog_1, which would result in a conflict of exported environment variables, you’ll see a validation error and you won’t be able to deploy such config.

Hostnames

All services, no matter the type and configuration, export their private hostname as ${SERVICE_NAME}_HOST.

Services made public, in addition to their private hostname, also export public one as ${SERVICE_NAME}_PUBLIC_HOST.

services:
  # Exports:
  # - WORKER_1_HOST
  worker-1: {}

  # Exports:
  # - MY_BLOG_HOST
  # - MY_BLOG_PUBLIC_HOST
  my_blog:
    public: true

Databases

Services of type postgres and valkey export database connection information, that other services can use to connect.

postgres exports

valkey exports

Sample deploy.yml connecting a service to databases

services:
  rails:
    env:
      DATABASE_URL: $PRIMARY_DB_URL # exported by "primary_db" service
      REDIS_URL: $MEMORY_DB_URL # exported by "memory_db" service

  primary_db:
    type: postgres

  memory_db:
    type: valkey