ci(deploy): config por entorno en /etc/localesp/<slug>.env
deploy-branch / deploy (push) Successful in 3m18s
deploy-branch / teardown (push) Skipped
tests / Unitarias + componente + build (push) Failing after 3m25s
tests / Integración (Nominatim real, opt-in) (push) Skipped
tests / Unitarias + componente + build (pull_request) Failing after 3m29s
tests / Integración (Nominatim real, opt-in) (pull_request) Skipped
deploy-branch / deploy (push) Successful in 3m18s
deploy-branch / teardown (push) Skipped
tests / Unitarias + componente + build (push) Failing after 3m25s
tests / Integración (Nominatim real, opt-in) (push) Skipped
tests / Unitarias + componente + build (pull_request) Failing after 3m29s
tests / Integración (Nominatim real, opt-in) (pull_request) Skipped
El build ahora exige LOCALESP_ADMIN_PREFIX (sin valor por defecto), así que el CI necesita saber el prefijo de cada entorno de rama: - deploy.yml: el paso de build carga /etc/localesp/<slug>.env del host (Slug::from de lib/env.sh) y falla con mensaje claro si no existe - env.sh: Env::require_config valida la config, y Env::deploy la copia a <dest>/.env, que el servidor autocarga (sobrevive a rsync --delete) - tests.yml: el smoke-build usa un prefijo placeholder (/admin-ci); comprueba que el build funciona, no la configuración del entorno
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
DOMAIN="localesp.es"
|
||||
PORT_BASE=8082 # 8080/8081 son entornos legacy
|
||||
ENV_CONFIG_DIR="/etc/localesp" # config por entorno: <slug>.env (ver Env::require_config)
|
||||
LOGGER_TAG="env"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -381,6 +382,7 @@ Env::new() {
|
||||
fi
|
||||
s[host]="${s[slug]}.$DOMAIN"
|
||||
s[dest]="/opt/localesp/${s[slug]}"
|
||||
s[config]="$ENV_CONFIG_DIR/${s[slug]}.env"
|
||||
s[unit_name]="localesp-${s[slug]}"
|
||||
s[port]="$(Port::acquire "${s[unit_name]}" "${s[dest]}")"
|
||||
|
||||
@@ -390,14 +392,35 @@ Env::new() {
|
||||
TlsCert::new "${self}__cert" "${s[host]}"
|
||||
}
|
||||
|
||||
# Config por entorno: /etc/localesp/<slug>.env debe existir y definir al menos
|
||||
# LOCALESP_ADMIN_PREFIX (obligatoria para servidor y build). Es config del
|
||||
# operador (no viaja en el repo): la creación es manual y teardown NO la borra.
|
||||
Env::require_config() {
|
||||
local self="$1"
|
||||
local -n s="$self"
|
||||
|
||||
if [ ! -f "${s[config]}" ]; then
|
||||
Logger::error "falta ${s[config]}: crea el fichero en el host con LOCALESP_ADMIN_PREFIX=<prefijo>"
|
||||
Logger::error "p. ej.: mkdir -p $ENV_CONFIG_DIR && echo 'LOCALESP_ADMIN_PREFIX=/administrador' > ${s[config]}"
|
||||
exit 1
|
||||
fi
|
||||
Logger::info "config por entorno: ${s[config]}"
|
||||
}
|
||||
|
||||
Env::deploy() {
|
||||
local self="$1"
|
||||
local -n s="$self"
|
||||
|
||||
Artifacts::require_built "${s[root]}"
|
||||
Env::require_config "$self"
|
||||
Logger::info "sincronizando artefactos -> ${s[dest]}"
|
||||
Artifacts::sync "${s[root]}" "${s[dest]}"
|
||||
|
||||
# El servidor autocarga <dest>/.env (no pisa variables del entorno);
|
||||
# rsync --delete sólo afecta a dist/ y server/, así que sobrevive, pero
|
||||
# se recopia en cada despliegue para seguir los cambios de la config.
|
||||
cp "${s[config]}" "${s[dest]}/.env"
|
||||
|
||||
Logger::info "instalando dependencias (prod)"
|
||||
Deps::install "${s[root]}" "${s[dest]}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user