diff --git a/deploy/deploy-by-script-to.sh b/deploy/deploy-by-script-to.sh index 5d5ddb8..3b1dd2d 100755 --- a/deploy/deploy-by-script-to.sh +++ b/deploy/deploy-by-script-to.sh @@ -93,7 +93,6 @@ fi # shellcheck source=lib/deploy-conf-handling.sh source "${DEPLOY_IA}/lib/deploy-conf-handling.sh" 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" fi diff --git a/deploy/lib/deploy-conf-handling.sh b/deploy/lib/deploy-conf-handling.sh index a8bdac4..85374aa 100644 --- a/deploy/lib/deploy-conf-handling.sh +++ b/deploy/lib/deploy-conf-handling.sh @@ -28,27 +28,6 @@ ia_dev_deploy_secrets_export_from_conf() { fi } -# ia_dev_deploy_export_site_code_from_conf — 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 # LeCoffre connect-db-paths expects `.secrets///` under secrets_parent. ia_dev conf often has a flat `/` tree only. # For each site in notary, enso, genealogie: if `//` is missing and `/` is a directory, diff --git a/deploy/orchestrator.sh b/deploy/orchestrator.sh index 6ac0ce3..dfdbac0 100755 --- a/deploy/orchestrator.sh +++ b/deploy/orchestrator.sh @@ -48,7 +48,6 @@ fi ia_dev_deploy_require_jq "${_ORCH_TAG}" 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_export_runtime_context "$REPO_ROOT" "${1:-}" ia_dev_deploy_assert_handoff_context "$REPO_ROOT" "${1:-}" "${_ORCH_TAG}" diff --git a/deploy/pousse.sh b/deploy/pousse.sh index 85eade8..6e72fc5 100755 --- a/deploy/pousse.sh +++ b/deploy/pousse.sh @@ -125,12 +125,10 @@ if [[ "$author_name" != "4NK" && "$author_name" != "Nicolas Cantu" ]]; then fi # Build dirs from project config (projects//conf.json); skip if no config or no build_dirs build_dirs=() -default_site_code="" if [[ -n "${PROJECT_CONFIG_PATH:-}" && -f "$PROJECT_CONFIG_PATH" ]] && command -v jq >/dev/null 2>&1; then while IFS= read -r d; do [[ -n "$d" ]] && build_dirs+=( "$d" ) 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 if [[ ${#build_dirs[@]} -gt 0 ]]; then # shellcheck source=../lib/conf_path_resolve.sh @@ -149,10 +147,10 @@ if [[ ${#build_dirs[@]} -gt 0 ]]; then continue fi 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 - echo "[pousse] Building ${dir} (NEXT_PUBLIC_SITE_CODE=${default_site_code})..." - (cd "$abs_dir" && env "NEXT_PUBLIC_SITE_CODE=${default_site_code}" npm run build) || { - echo "[pousse][ERROR] Build failed in ${dir}" >&2 + if [[ -z "${NEXT_PUBLIC_SITE_CODE:-}" && ( "$build_basename" == "front-common" || "$build_basename" == "lecoffre-front-main" ) ]]; then + echo "[pousse] Building ${dir} (npm run build:all-sites: notary, enso, genealogie)..." + (cd "$abs_dir" && npm run build:all-sites) || { + echo "[pousse][ERROR] build:all-sites failed in ${dir}" >&2 exit 1 } continue diff --git a/projects/lecoffreio/conf.json b/projects/lecoffreio/conf.json index 5d280f0..31fa89b 100644 --- a/projects/lecoffreio/conf.json +++ b/projects/lecoffreio/conf.json @@ -13,7 +13,6 @@ "deploy_script_path": "/home/desk/code/lecoffre_ng_test/deploy/scripts_v2/deploy.sh", "project_orchestrator_path": "deploy/scripts_v2/deploy.sh", "secrets_path": "/home/desk/code/ia_dev/projects/lecoffreio/.secrets", - "default_site_code": "notary", "host_stays_on_test": true }, "version": { diff --git a/projects/lecoffreio/docs/Deployment.md b/projects/lecoffreio/docs/Deployment.md index 96a5f9c..09e5994 100644 --- a/projects/lecoffreio/docs/Deployment.md +++ b/projects/lecoffreio/docs/Deployment.md @@ -71,7 +71,7 @@ Liste des fichiers contenant les textes affichés à l’utilisateur (libellés, ## Déploiement applicatif -- **Multi-site (`SITE_CODE`, secrets imbriqués)** : les scripts applicatifs (`deploy/scripts_v2`, `connect-db-paths.sh`) attendent **`.secrets///`** avec **`site ∈ { notary, enso, genealogie }`**. Sous **`projects/lecoffreio/conf.json`**, **`deploy.secrets_path`** pointe souvent vers un arbre **plat** **`//`** 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 **`//`** n’existe pas encore et que **`//`** est un répertoire, créent un lien symbolique **`../`** (é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 n’est 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///`** avec **`site ∈ { notary, enso, genealogie }`**. **`SITE_CODE`** (ou **`LECOFFRE_SITE_CODE`** / **`DEPLOY_SITE_CODE`**) doit être **exporté explicitement** avant ces scripts ; l’orchestrateur **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** **`//`** uniquement : **`orchestrator.sh`** et **`deploy/deploy-by-script-to.sh`** peuvent alors créer pour chaque site **notary**, **enso**, **genealogie** un lien **`//` → `../`** si l’emplacement imbriqué n’existe pas encore et que **`//`** est un répertoire. Un répertoire **réel** (non lien) existant n’est 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 [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). - **Clé SSH déploiement (`DEPLOY_SSH_KEY`)** : définie dans `.secrets//.env.`. Utiliser un chemin **portable** : par ex. `DEPLOY_SSH_KEY='$HOME/.ssh/id_ed25519_4nk'` (l’expansion 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 ` ou les trois d’un coup : `bash deploy/scripts_v2/run-verify-ssh-all-envs.sh`.