changemaker.lite/nginx/entrypoint.sh
bunker-admin abdfd50cb8 Make embed proxy ports configurable via env vars for multi-instance deployments
All 13 nginx embed proxy ports (8881-8895) are now driven by environment
variables instead of being hardcoded. This prevents port conflicts when
running multiple Changemaker instances on the same host.

Chain: .env → docker-compose port mappings → nginx container env →
entrypoint.sh envsubst → services.conf.template listen directives →
API /services/config endpoint → frontend buildServiceUrl().

Existing deployments are unaffected (all vars default to current values).

Bunker Admin
2026-03-25 15:25:00 -06:00

45 lines
1.9 KiB
Bash
Executable File

#!/bin/sh
set -e
# Default domain if not set
export DOMAIN=${DOMAIN:-cmlite.org}
# Default embed proxy ports (configurable via .env for multi-instance deployments)
export NOCODB_EMBED_PORT=${NOCODB_EMBED_PORT:-8881}
export N8N_EMBED_PORT=${N8N_EMBED_PORT:-8882}
export GITEA_EMBED_PORT=${GITEA_EMBED_PORT:-8883}
export MAILHOG_EMBED_PORT=${MAILHOG_EMBED_PORT:-8884}
export MINI_QR_EMBED_PORT=${MINI_QR_EMBED_PORT:-8885}
export EXCALIDRAW_EMBED_PORT=${EXCALIDRAW_EMBED_PORT:-8886}
export HOMEPAGE_EMBED_PORT=${HOMEPAGE_EMBED_PORT:-8887}
export VAULTWARDEN_EMBED_PORT=${VAULTWARDEN_EMBED_PORT:-8890}
export ROCKETCHAT_EMBED_PORT=${ROCKETCHAT_EMBED_PORT:-8891}
export GANCIO_EMBED_PORT=${GANCIO_EMBED_PORT:-8892}
export JITSI_EMBED_PORT=${JITSI_EMBED_PORT:-8893}
export GRAFANA_EMBED_PORT=${GRAFANA_EMBED_PORT:-8894}
export ALERTMANAGER_EMBED_PORT=${ALERTMANAGER_EMBED_PORT:-8895}
echo "Configuring nginx for domain: $DOMAIN"
# List of environment variables to substitute in templates
# IMPORTANT: must be explicit to avoid replacing nginx variables like $host, $remote_addr
VARS='${DOMAIN}'
VARS="${VARS} \${NOCODB_EMBED_PORT} \${N8N_EMBED_PORT} \${GITEA_EMBED_PORT}"
VARS="${VARS} \${MAILHOG_EMBED_PORT} \${MINI_QR_EMBED_PORT} \${EXCALIDRAW_EMBED_PORT}"
VARS="${VARS} \${HOMEPAGE_EMBED_PORT} \${VAULTWARDEN_EMBED_PORT} \${ROCKETCHAT_EMBED_PORT}"
VARS="${VARS} \${GANCIO_EMBED_PORT} \${JITSI_EMBED_PORT} \${GRAFANA_EMBED_PORT}"
VARS="${VARS} \${ALERTMANAGER_EMBED_PORT}"
# Template nginx configuration files with environment variables
envsubst "$VARS" < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf
envsubst "$VARS" < /etc/nginx/conf.d/api.conf.template > /etc/nginx/conf.d/api.conf
envsubst "$VARS" < /etc/nginx/conf.d/services.conf.template > /etc/nginx/conf.d/services.conf
echo "Nginx configuration templated successfully"
# Test configuration
nginx -t
# Execute the original nginx entrypoint
exec /docker-entrypoint.sh "$@"