Env placeholders

Table of contents

Introduction

A feature’s .env files can hold two placeholders that the CLI fills in when it merges them, __PRODUCT__ and __FEATURE_HOST_DIR__. They cover values a feature cannot know until a product uses it, such as a container name or a host path.

# the feature's docker/.env.example
PROXY_UPSTREAM_HOST=__PRODUCT___web

In a product named my_first_app, product:env --merge writes PROXY_UPSTREAM_HOST=my_first_app_web. Plain settings and their defaults go in the feature’s pyproject.toml instead. See Feature settings.


Naming the product with __PRODUCT__

__PRODUCT__ becomes the product’s name. In production the web container is <product>_web_deploy, so __PRODUCT___web becomes that, and any other __PRODUCT__ the product name.

  product  resolved __PRODUCT__ in 1 variable(s) → my_first_app

Only values are replaced, never keys. The port offset is applied first. When your product’s own env file sets the variable, the feature’s value is ignored.


Mounting feature files with __FEATURE_HOST_DIR__

__FEATURE_HOST_DIR__ becomes the host’s absolute path of the feature’s directory, editable or pinned. Compose runs in the CLI container, but the Docker daemon mounts host paths, so a feature needs this to mount its own files.

# the feature's docker/.env.example
PROXY_FEATURE_HOST_DIR=__FEATURE_HOST_DIR__
# the feature's docker-compose.dev.yml
volumes:
  - ${PROXY_FEATURE_HOST_DIR}/docker/nginx/templates/default.dev.conf.template:/etc/nginx/templates/default.conf.template:ro

After the merge it reads /Users/dev/splent_workspace/splent_feature_proxy, or the snapshot’s path under .splent_cache/. It is written into the feature’s own docker/.env too, so docker compose sees it. SPLENT_HOST_PROJECT_DIR tells the CLI where the workspace is on the host.

In production, product:build drops these variables, copies the feature’s files into deploy/features/<service>/, and rewrites each mount to ${SPLENT_HOST_DEPLOY_DIR:-.}/features/<service>/<path>. The bundle never carries the path of the machine that built it.


Reference

Placeholder Development Production
__PRODUCT___web <product>_web <product>_web_deploy
__PRODUCT__ elsewhere <product> <product>
__FEATURE_HOST_DIR__ The host path of the feature Removed. Mounts point at deploy/features/<service>/

See also


Back to top

splent. Distributed by an LGPL license v3. Contact us: drorganvidez@us.es