refactor(deploy): drop default_site_code; pousse builds all front sites

- Remove ia_dev_deploy_export_site_code_from_conf and conf.json key.
- pousse: front-common uses npm run build:all-sites when NEXT_PUBLIC_SITE_CODE unset.
- Keep nested .secrets/<site>/<env> symlinks helper.
- Update lecoffreio Deployment.md.
This commit is contained in:
Nicolas Cantu 2026-04-13 23:56:19 +02:00
parent a2ea98801f
commit 6e10b44e7d
6 changed files with 5 additions and 31 deletions

View File

@ -93,7 +93,6 @@ fi
# shellcheck source=lib/deploy-conf-handling.sh # shellcheck source=lib/deploy-conf-handling.sh
source "${DEPLOY_IA}/lib/deploy-conf-handling.sh" source "${DEPLOY_IA}/lib/deploy-conf-handling.sh"
if [[ -n "${PROJECT_CONFIG_PATH:-}" && -f "${PROJECT_CONFIG_PATH}" ]]; then if [[ -n "${PROJECT_CONFIG_PATH:-}" && -f "${PROJECT_CONFIG_PATH}" ]]; then
ia_dev_deploy_export_site_code_from_conf "$PROJECT_CONFIG_PATH"
ia_dev_deploy_ensure_nested_secrets_symlinks "$SECRETS_PARENT" "$TARGET_BRANCH" ia_dev_deploy_ensure_nested_secrets_symlinks "$SECRETS_PARENT" "$TARGET_BRANCH"
fi fi

View File

@ -28,27 +28,6 @@ ia_dev_deploy_secrets_export_from_conf() {
fi fi
} }
# ia_dev_deploy_export_site_code_from_conf <conf_path> — if SITE_CODE, LECOFFRE_SITE_CODE and DEPLOY_SITE_CODE are all unset,
# export them from deploy.default_site_code (LeCoffre multi-site: notary | enso | genealogie). Explicit env always wins.
ia_dev_deploy_export_site_code_from_conf() {
local conf="${1:?}"
if ! command -v jq >/dev/null 2>&1; then
return 0
fi
if [[ -n "${SITE_CODE:-}" || -n "${LECOFFRE_SITE_CODE:-}" || -n "${DEPLOY_SITE_CODE:-}" ]]; then
return 0
fi
local site
site="$(jq -r '.deploy.default_site_code // empty' "$conf" 2>/dev/null | tr -d '\r' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
if [[ -z "$site" || "$site" == "null" ]]; then
return 0
fi
export SITE_CODE="$site"
export LECOFFRE_SITE_CODE="$site"
export DEPLOY_SITE_CODE="$site"
echo "[ia_dev][deploy] SITE_CODE unset; using deploy.default_site_code from conf: ${site}" >&2
}
# ia_dev_deploy_ensure_nested_secrets_symlinks <secrets_parent> <env> # ia_dev_deploy_ensure_nested_secrets_symlinks <secrets_parent> <env>
# LeCoffre connect-db-paths expects `.secrets/<site>/<env>/` under secrets_parent. ia_dev conf often has a flat `<env>/` tree only. # LeCoffre connect-db-paths expects `.secrets/<site>/<env>/` under secrets_parent. ia_dev conf often has a flat `<env>/` tree only.
# For each site in notary, enso, genealogie: if `<secrets_parent>/<site>/<env>` is missing and `<secrets_parent>/<env>` is a directory, # For each site in notary, enso, genealogie: if `<secrets_parent>/<site>/<env>` is missing and `<secrets_parent>/<env>` is a directory,

View File

@ -48,7 +48,6 @@ fi
ia_dev_deploy_require_jq "${_ORCH_TAG}" ia_dev_deploy_require_jq "${_ORCH_TAG}"
ia_dev_deploy_secrets_export_from_conf "$CONF" ia_dev_deploy_secrets_export_from_conf "$CONF"
ia_dev_deploy_export_site_code_from_conf "$CONF"
ia_dev_deploy_ensure_nested_secrets_symlinks "${SECRETS_BASE:-}" "${1:-}" ia_dev_deploy_ensure_nested_secrets_symlinks "${SECRETS_BASE:-}" "${1:-}"
ia_dev_deploy_export_runtime_context "$REPO_ROOT" "${1:-}" ia_dev_deploy_export_runtime_context "$REPO_ROOT" "${1:-}"
ia_dev_deploy_assert_handoff_context "$REPO_ROOT" "${1:-}" "${_ORCH_TAG}" ia_dev_deploy_assert_handoff_context "$REPO_ROOT" "${1:-}" "${_ORCH_TAG}"

View File

@ -125,12 +125,10 @@ if [[ "$author_name" != "4NK" && "$author_name" != "Nicolas Cantu" ]]; then
fi fi
# Build dirs from project config (projects/<id>/conf.json); skip if no config or no build_dirs # Build dirs from project config (projects/<id>/conf.json); skip if no config or no build_dirs
build_dirs=() build_dirs=()
default_site_code=""
if [[ -n "${PROJECT_CONFIG_PATH:-}" && -f "$PROJECT_CONFIG_PATH" ]] && command -v jq >/dev/null 2>&1; then if [[ -n "${PROJECT_CONFIG_PATH:-}" && -f "$PROJECT_CONFIG_PATH" ]] && command -v jq >/dev/null 2>&1; then
while IFS= read -r d; do while IFS= read -r d; do
[[ -n "$d" ]] && build_dirs+=( "$d" ) [[ -n "$d" ]] && build_dirs+=( "$d" )
done < <(jq -r '.build_dirs[]? // empty' "$PROJECT_CONFIG_PATH" 2>/dev/null) done < <(jq -r '.build_dirs[]? // empty' "$PROJECT_CONFIG_PATH" 2>/dev/null)
default_site_code="$(jq -r '.deploy.default_site_code // empty' "$PROJECT_CONFIG_PATH" 2>/dev/null)"
fi fi
if [[ ${#build_dirs[@]} -gt 0 ]]; then if [[ ${#build_dirs[@]} -gt 0 ]]; then
# shellcheck source=../lib/conf_path_resolve.sh # shellcheck source=../lib/conf_path_resolve.sh
@ -149,10 +147,10 @@ if [[ ${#build_dirs[@]} -gt 0 ]]; then
continue continue
fi fi
build_basename="$(basename "$abs_dir")" build_basename="$(basename "$abs_dir")"
if [[ -n "$default_site_code" && -z "${NEXT_PUBLIC_SITE_CODE:-}" && ( "$build_basename" == "front-common" || "$build_basename" == "lecoffre-front-main" ) ]]; then if [[ -z "${NEXT_PUBLIC_SITE_CODE:-}" && ( "$build_basename" == "front-common" || "$build_basename" == "lecoffre-front-main" ) ]]; then
echo "[pousse] Building ${dir} (NEXT_PUBLIC_SITE_CODE=${default_site_code})..." echo "[pousse] Building ${dir} (npm run build:all-sites: notary, enso, genealogie)..."
(cd "$abs_dir" && env "NEXT_PUBLIC_SITE_CODE=${default_site_code}" npm run build) || { (cd "$abs_dir" && npm run build:all-sites) || {
echo "[pousse][ERROR] Build failed in ${dir}" >&2 echo "[pousse][ERROR] build:all-sites failed in ${dir}" >&2
exit 1 exit 1
} }
continue continue

View File

@ -13,7 +13,6 @@
"deploy_script_path": "/home/desk/code/lecoffre_ng_test/deploy/scripts_v2/deploy.sh", "deploy_script_path": "/home/desk/code/lecoffre_ng_test/deploy/scripts_v2/deploy.sh",
"project_orchestrator_path": "deploy/scripts_v2/deploy.sh", "project_orchestrator_path": "deploy/scripts_v2/deploy.sh",
"secrets_path": "/home/desk/code/ia_dev/projects/lecoffreio/.secrets", "secrets_path": "/home/desk/code/ia_dev/projects/lecoffreio/.secrets",
"default_site_code": "notary",
"host_stays_on_test": true "host_stays_on_test": true
}, },
"version": { "version": {

View File

@ -71,7 +71,7 @@ Liste des fichiers contenant les textes affichés à lutilisateur (libellés,
## Déploiement applicatif ## Déploiement applicatif
- **Multi-site (`SITE_CODE`, secrets imbriqués)** : les scripts applicatifs (`deploy/scripts_v2`, `connect-db-paths.sh`) attendent **`.secrets/<site>/<env>/`** avec **`site ∈ { notary, enso, genealogie }`**. Sous **`projects/lecoffreio/conf.json`**, **`deploy.secrets_path`** pointe souvent vers un arbre **plat** **`<secrets_path>/<env>/`** uniquement. L**orchestrateur ia_dev** (`deploy/orchestrator.sh`) et **`deploy/deploy-by-script-to.sh`** : (1) exportent **`SITE_CODE`**, **`LECOFFRE_SITE_CODE`** et **`DEPLOY_SITE_CODE`** à partir de **`deploy.default_site_code`** lorsque ces trois variables sont encore vides (une exportation explicite dans le shell reste prioritaire) ; (2) pour chaque site **notary**, **enso**, **genealogie**, si **`<secrets_path>/<site>/<env>`** nexiste pas encore et que **`<secrets_path>/<env>/`** est un répertoire, créent un lien symbolique **`../<env>`** (équivalent manuel : `mkdir -p notary && ln -sfn ../test notary/test`). Si un répertoire **réel** (non lien) existe déjà pour un site, il nest pas écrasé. Pour des secrets **distincts** par site sur la même machine, remplacer le lien par un vrai répertoire et fichiers dédiés. - **Multi-site (`SITE_CODE`, secrets imbriqués)** : les scripts applicatifs (`deploy/scripts_v2`, `connect-db-paths.sh`) attendent **`.secrets/<site>/<env>/`** avec **`site ∈ { notary, enso, genealogie }`**. **`SITE_CODE`** (ou **`LECOFFRE_SITE_CODE`** / **`DEPLOY_SITE_CODE`**) doit être **exporté explicitement** avant ces scripts ; lorchestrateur **ia_dev** ne le déduit pas depuis le `conf.json`. Sous **`projects/lecoffreio/conf.json`**, **`deploy.secrets_path`** pointe souvent vers un arbre **plat** **`<secrets_path>/<env>/`** uniquement : **`orchestrator.sh`** et **`deploy/deploy-by-script-to.sh`** peuvent alors créer pour chaque site **notary**, **enso**, **genealogie** un lien **`<secrets_path>/<site>/<env>``../<env>`** si lemplacement imbriqué nexiste pas encore et que **`<secrets_path>/<env>/`** est un répertoire. Un répertoire **réel** (non lien) existant nest pas écrasé ; pour des secrets **distincts** par site, remplacer le lien par un vrai répertoire.
- **Orchestration ia_dev** : depuis la racine du dépôt ia_dev, `./deploy/deploy.sh <project_id> <env> [options]` exporte `IA_PROJECT_ID` puis exécute `orchestrator.sh`. Celui-ci enchaîne les scripts listés dans `deploy.hooks.phases` du `conf.json` du projet (chemins relatifs à `repository_root`), ou exécute `deploy.deploy_script_path` si `phases` est vide. `run-project-hooks.sh` délègue à `orchestrator.sh` (compatibilité). Cadrage : `deploy/DEPLOY_ORCHESTRATION_IA_DEV.md`. - **Orchestration ia_dev** : depuis la racine du dépôt ia_dev, `./deploy/deploy.sh <project_id> <env> [options]` exporte `IA_PROJECT_ID` puis exécute `orchestrator.sh`. Celui-ci enchaîne les scripts listés dans `deploy.hooks.phases` du `conf.json` du projet (chemins relatifs à `repository_root`), ou exécute `deploy.deploy_script_path` si `phases` est vide. `run-project-hooks.sh` délègue à `orchestrator.sh` (compatibilité). Cadrage : `deploy/DEPLOY_ORCHESTRATION_IA_DEV.md`.
- **Scripts** : `deploy/scripts_v2/` ; chemin projet dans ia_dev `projects/lecoffreio/conf.json` (project_path, build_dirs, deploy.deploy_script_path, deploy.secrets_path). - **Scripts** : `deploy/scripts_v2/` ; chemin projet dans ia_dev `projects/lecoffreio/conf.json` (project_path, build_dirs, deploy.deploy_script_path, deploy.secrets_path).
- **Clé SSH déploiement (`DEPLOY_SSH_KEY`)** : définie dans `.secrets/<env>/.env.<env>`. Utiliser un chemin **portable** : par ex. `DEPLOY_SSH_KEY='$HOME/.ssh/id_ed25519_4nk'` (lexpansion de `$HOME`, `${HOME}` et un préfixe `~/` est appliquée par `lecoffre_deploy_resolve_deploy_ssh_key` après `load_dotenv_file_strict`, qui ne fait pas d`eval`). Ne pas figer un autre compte système (`/home/desk/...`). Ordre de repli si la clé indiquée est absente : `$HOME/.ssh/id_ed25519_4nk`, puis `$HOME/.ssh/id_ed25519`. Avant toute connexion SSH, la clé retenue est validée avec `ssh-keygen -y`. Vérification réseau : `bash deploy/scripts_v2/run-verify-ssh.sh <env>` ou les trois dun coup : `bash deploy/scripts_v2/run-verify-ssh-all-envs.sh`. - **Clé SSH déploiement (`DEPLOY_SSH_KEY`)** : définie dans `.secrets/<env>/.env.<env>`. Utiliser un chemin **portable** : par ex. `DEPLOY_SSH_KEY='$HOME/.ssh/id_ed25519_4nk'` (lexpansion de `$HOME`, `${HOME}` et un préfixe `~/` est appliquée par `lecoffre_deploy_resolve_deploy_ssh_key` après `load_dotenv_file_strict`, qui ne fait pas d`eval`). Ne pas figer un autre compte système (`/home/desk/...`). Ordre de repli si la clé indiquée est absente : `$HOME/.ssh/id_ed25519_4nk`, puis `$HOME/.ssh/id_ed25519`. Avant toute connexion SSH, la clé retenue est validée avec `ssh-keygen -y`. Vérification réseau : `bash deploy/scripts_v2/run-verify-ssh.sh <env>` ou les trois dun coup : `bash deploy/scripts_v2/run-verify-ssh-all-envs.sh`.