Manage the CLI environment

Table of contents

  1. Introduction
  2. What make setup does
  3. Knowing which product is selected
  4. The workspace .env
    1. How the repairs write .env
  5. The pre-flight
  6. Fixing common problems

Introduction

The make targets of the CLI repository run on your host, before you are inside the container. They create and repair the workspace .env, start the CLI container and open its shell. Once inside, you use splent commands instead.

The first time, run this from splent_cli/.

make setup
πŸ› οΈ  SPLENT fix-workdir

  [βœ”] SPLENT_HOST_PROJECT_DIR set to /home/me/splent_workspace
  ...

🩺 SPLENT CLI pre-flight

  [βœ”] Docker installed, Docker version 29.2.1, build a5c7197d72
  ...

βœ… Pre-flight passed.

🐳 Starting containers...
🐳 Using UID=1000 GID=1000
🧠 Entering SPLENT CLI...
(detached) /workspace$

Every step is safe to run again. From then on, make cli is all you need.


What make setup does

The steps of make setup env-prepare creates, repairs .env Pre-flight Docker, Compose, .env compose up -d starts the container cli-enter quiet check, shell make docker-up make setup
make setup is make docker-up followed by cli-enter, so the shell opens on a correct .env and a checked container.

Each step is a target you can also run alone.

Target What it does
make setup Prepares .env, starts Docker and enters the CLI
make setup-rebuild Tears down, rebuilds the images from scratch and enters. Destructive, asks first
make docker-up Prepares .env, then starts the container
make cli Enters the running container
make help Lists every target
make env-prepare Creates .env from the template and repairs it
make env-check Validates .env
make fix-workdir Repairs SPLENT_HOST_PROJECT_DIR and WORKING_DIR
make fix-app Clears a dangling SPLENT_APP
make fix-env Repairs, then validates
make preflight Runs the host checks only

Only make setup-rebuild removes data.


Knowing which product is selected

Inside the container, the prompt tells you.

Prompt Meaning
(detached) /workspace$ No product selected
(my_product) /workspace$ SPLENT_APP=my_product and the folder exists
(my_product?) /workspace$ SPLENT_APP names a missing folder. Run make fix-app

The workspace .env

splent_workspace/
β”œβ”€β”€ .env              ← the real file (git-ignored, host-specific)
β”œβ”€β”€ splent_cli/
β”‚   β”œβ”€β”€ .env.example  ← the committed template
β”‚   β”œβ”€β”€ Makefile
β”‚   └── scripts/
β”œβ”€β”€ splent_framework/
└── <your products>/

It sits at the workspace root, one level above splent_cli/, and starts as a copy of the committed template.

Variable Set by Purpose
WORKING_DIR template The workspace inside the container, always /workspace
SPLENT_HOST_PROJECT_DIR fix-workdir The same folder on the host. Product containers bind-mount it through the Docker socket
SPLENT_APP splent product:select The selected product’s name. Unset means detached mode. See Another product for one command
SPLENT_APP_DIR splent product:select The folder the selected product is checked out in, which need not be its name
SPLENT_ENV splent product:up, splent product:deploy dev or prod, written into the product’s docker/.env, which the CLI loads while the product is selected. dev when unset
SPLENT_FORGE_USER, SPLENT_FORGE_TOKEN you, or splent env:set forge Your forge account, to clone and release over HTTPS. GITHUB_USER and GITHUB_TOKEN are read when they are unset
SPLENT_FORGE_HOST, SPLENT_FORGE_SSH_HOST, SPLENT_FORGE_SSH_PORT, SPLENT_FORGE_API you, optional The forge that hosts the features. Empty means git.splent.io, SSH on port 2223
TWINE_USERNAME, TWINE_PASSWORD you, or splent env:set pypi PyPI credentials for publishing

How the repairs write .env

env-prepare, fix-workdir, fix-app and fix-env change only the keys they repair, indented and export-prefixed ones included, and keep every other line.

  • They write through a temporary file next to .env and keep its mode, or its target’s when .env is a symlink.
  • A value with spaces or shell-special characters, such as a workspace under my projects, is written single-quoted. Docker Compose, python-dotenv and bash all read it literally.
  • When you cannot read and write .env, they change nothing and exit 1.
Cannot read and write <path>, so it was left untouched.
Make it a regular file you own (for example: chmod 600 <path>), then re-run.

The pre-flight

Every target that starts or enters the container first runs the host pre-flight. It checks Docker, Compose, your git and SSH setup and the .env. A duplicate or malformed key stops it. A stale host path or a dangling product only warns and names the repair.


Fixing common problems

Symptom Run
You moved or renamed the workspace folder make fix-workdir
The prompt shows (name?) in yellow make fix-app
Duplicate variable … Keep one line, then make env-check
.env not found make env-prepare
Container is bound to another workspace make docker-up recreates it for this workspace
Docker daemon is not responding Start Docker, then make preflight
The image is stale after Docker or dependency changes make setup-rebuild

Table of contents


Back to top

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