-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
31 lines (26 loc) · 1.38 KB
/
docker-entrypoint.sh
File metadata and controls
31 lines (26 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
set -e
# Validar que las variables requeridas estén definidas (COMPANY_NAME es opcional)
if [ -z "$BRAND_NAME" ] || [ -z "$SYSTEM_URL" ]; then
echo "ERROR: Variables de entorno requeridas no definidas"
echo " BRAND_NAME: ${BRAND_NAME:-'NO DEFINIDO'}"
echo " SYSTEM_URL: ${SYSTEM_URL:-'NO DEFINIDO'}"
echo ""
echo "Defina estas variables en docker-compose.yml"
exit 1
fi
# COMPANY_NAME es opcional: si no se define, se usa BRAND_NAME como fallback
COMPANY_NAME="${COMPANY_NAME:-$BRAND_NAME}"
echo "Configuracion: BRAND_NAME=$BRAND_NAME SYSTEM_URL=$SYSTEM_URL COMPANY_NAME=$COMPANY_NAME"
# Procesar templates de nginx: reemplaza ${BRAND_NAME}, ${SYSTEM_URL}, ${COMPANY_NAME}
# en los archivos *.template de /etc/nginx/templates/ y los escribe en /etc/nginx/conf.d/
# Esto es necesario porque este entrypoint reemplaza al oficial de nginx, que es quien
# normalmente ejecuta el envsubst sobre los templates.
for template in /etc/nginx/templates/*.template; do
[ -f "$template" ] || continue
output="/etc/nginx/conf.d/$(basename "$template" .template)"
# Especificar variables explícitamente para no corromper variables internas de nginx ($uri, $host, etc.)
envsubst '${BRAND_NAME} ${SYSTEM_URL} ${COMPANY_NAME}' < "$template" > "$output"
echo "Template procesado: $(basename "$template") -> $(basename "$output")"
done
exec nginx -g 'daemon off;'