This is an automated email from the ASF dual-hosted git repository.

abeizn pushed a commit to branch release-v1.0
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 4287750aeecbd1bbcbda3ae446a827480d55a7bc
Author: ivan sumak <[email protected]>
AuthorDate: Thu Mar 21 15:48:44 2024 +0100

    fixing #7100 by adding auto-discovery of interface type (ipv4/ipv6) inside 
container (#7197)
    
    Co-authored-by: Ivan Ĺ umak <[email protected]>
---
 config-ui/Dockerfile |  2 +-
 config-ui/nginx.conf |  3 +--
 config-ui/nginx.sh   | 19 ++++++++++++++++++-
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/config-ui/Dockerfile b/config-ui/Dockerfile
index 78117ae2d..c094df4fe 100644
--- a/config-ui/Dockerfile
+++ b/config-ui/Dockerfile
@@ -41,7 +41,7 @@ WORKDIR /usr/share/nginx/html
 RUN rm -rf ./*
 COPY --from=builder /home/node/code/dist/. ./
 EXPOSE 4000 4443
-RUN apt update && apt install -y apache2-utils
+RUN apt update && apt install -y apache2-utils iproute2
 COPY --from=builder /home/node/code/nginx.sh /usr/bin/nginx.sh
 RUN chmod +x /usr/bin/nginx.sh
 USER 101
diff --git a/config-ui/nginx.conf b/config-ui/nginx.conf
index 249af4530..6e2b7f84d 100644
--- a/config-ui/nginx.conf
+++ b/config-ui/nginx.conf
@@ -1,6 +1,5 @@
 server {
-  listen 4000;
-  listen [::]:4000;
+${LISTENER}
   server_name localhost;
   absolute_redirect off;
   client_max_body_size 20m;
diff --git a/config-ui/nginx.sh b/config-ui/nginx.sh
index cdb981b57..3e216b451 100755
--- a/config-ui/nginx.sh
+++ b/config-ui/nginx.sh
@@ -17,6 +17,23 @@
 #
 
 set -e
+
+
+if (ip -4 addr | grep -q "inet") && ! (ip -6 addr | grep -q "inet6"); then
+  export LISTENER='
+  listen 4000;
+  '
+elif ! (ip -4 addr | grep -q "inet") && (ip -6 addr | grep -q "inet6"); then
+  export LISTENER='
+  listen [::]:4000;
+  '
+else
+  export LISTENER='
+  listen 4000;
+  listen [::]:4000;
+  '
+fi
+
 if [ -n "$ADMIN_USER" ] && [ -n "$ADMIN_PASS" ]; then
     htpasswd -c -b /etc/nginx/.htpasswd "$ADMIN_USER" "$ADMIN_PASS"
     export SERVER_CONF='
@@ -28,7 +45,7 @@ export DNS=$(awk 'BEGIN{ORS=" "} $1=="nameserver" {if ($2 ~ 
":") {print "["$2"]"
 export DNS_VALID=${DNS_VALID:-300s}
 export DEVLAKE_ENDPOINT_PROTO=${DEVLAKE_ENDPOINT_PROTO:-http}
 export GRAFANA_ENDPOINT_PROTO=${GRAFANA_ENDPOINT_PROTO:-http}
-envsubst '${DEVLAKE_ENDPOINT} ${DEVLAKE_ENDPOINT_PROTO} ${GRAFANA_ENDPOINT} 
${GRAFANA_ENDPOINT_PROTO} ${USE_EXTERNAL_GRAFANA} ${SERVER_CONF} ${DNS} 
${DNS_VALID}' \
+envsubst '${LISTENER} ${DEVLAKE_ENDPOINT} ${DEVLAKE_ENDPOINT_PROTO} 
${GRAFANA_ENDPOINT} ${GRAFANA_ENDPOINT_PROTO} ${USE_EXTERNAL_GRAFANA} 
${SERVER_CONF} ${DNS} ${DNS_VALID}' \
     < /etc/nginx/conf.d/default.conf.tpl \
     > /etc/nginx/conf.d/default.conf
 nginx -g 'daemon off;'

Reply via email to