ci(deploy): alias rama -> entorno (prototipo-ef publica en prototipo-yb01.localesp.es)
Sólo hay un subdominio libre configurado (prototipo-yb01.localesp.es), así
que la rama prototipo-ef no puede publicar en prototipo-ef.localesp.es.
- scripts/entornos.alias.env: mapping <slug-rama>=<slug-entorno> (del repo,
revisable en PR). Sin entrada, la rama usa su propio slug.
- EnvSlug::environment + uso en Env:🆕 con alias, la rama reutiliza host,
unit systemd, puerto, destino y vhost del entorno indicado; Port::acquire
y NginxVhost::find_path ya adoptan los existentes.
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
# entornos.alias.env — alias rama -> entorno (una línea: <slug-rama>=<slug-entorno>)
|
||||||
|
#
|
||||||
|
# Por defecto cada rama publica en <slug-rama>.localesp.es. Con un alias, la
|
||||||
|
# rama comparte HOST, unit systemd, puerto y vhost con otro entorno, que es lo
|
||||||
|
# que hace falta cuando el DNS sólo tiene configurado un subdominio.
|
||||||
|
#
|
||||||
|
# prototipo-ef -> se publica en prototipo-yb01.localesp.es (único subdominio
|
||||||
|
# disponible), ocupando el entorno prototipo-yb01.
|
||||||
|
prototipo-ef=prototipo-yb01
|
||||||
+21
-1
@@ -25,6 +25,7 @@
|
|||||||
DOMAIN="localesp.es"
|
DOMAIN="localesp.es"
|
||||||
PORT_BASE=8082 # 8080/8081 son entornos legacy
|
PORT_BASE=8082 # 8080/8081 son entornos legacy
|
||||||
LOGGER_TAG="env"
|
LOGGER_TAG="env"
|
||||||
|
ENV_ALIAS_FILE="scripts/entornos.alias.env" # mapping slug-rama=slug-entorno (fichero del repo)
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Logger — servicio singleton (tag configurable según entrypoint).
|
# Logger — servicio singleton (tag configurable según entrypoint).
|
||||||
@@ -49,6 +50,25 @@ Slug::from() {
|
|||||||
printf '%s' "$branch" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//'
|
printf '%s' "$branch" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# EnvSlug — servicio estático: alias rama -> entorno.
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# scripts/entornos.alias.env mapea <slug-rama>=<slug-entorno>. Con alias, la
|
||||||
|
# rama reutiliza host, unit, puerto, destino y vhost del entorno indicado; sin
|
||||||
|
# alias, el entorno es la propia rama (comportamiento histórico).
|
||||||
|
EnvSlug::environment() {
|
||||||
|
local slug="$1"
|
||||||
|
local root="${2:-.}"
|
||||||
|
local alias
|
||||||
|
|
||||||
|
alias="$(grep -E "^[[:space:]]*${slug}[[:space:]]*=" "$root/$ENV_ALIAS_FILE" 2>/dev/null | tail -1 | cut -d= -f2- | tr -d '[:space:]')"
|
||||||
|
if [ -n "$alias" ]; then
|
||||||
|
printf '%s' "$alias"
|
||||||
|
else
|
||||||
|
printf '%s' "$slug"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Host — servicio estático: IP pública y resolución DNS.
|
# Host — servicio estático: IP pública y resolución DNS.
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@@ -374,7 +394,7 @@ Env::new() {
|
|||||||
|
|
||||||
s[branch]="$branch"
|
s[branch]="$branch"
|
||||||
s[root]="$root"
|
s[root]="$root"
|
||||||
s[slug]="$(Slug::from "$branch")"
|
s[slug]="$(EnvSlug::environment "$(Slug::from "$branch")" "$root")"
|
||||||
if [ -z "${s[slug]}" ]; then
|
if [ -z "${s[slug]}" ]; then
|
||||||
Logger::error "slug vacío para la rama '$branch'"
|
Logger::error "slug vacío para la rama '$branch'"
|
||||||
exit 2
|
exit 2
|
||||||
|
|||||||
Reference in New Issue
Block a user