diff --git a/Dockerfile b/Dockerfile index 098bf7a2c..85275f75b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ RUN npm run build FROM registry.suse.com/bci/bci-base:15.4 RUN zypper -n ref && \ - zypper -n install curl libxml2 bash gettext shadow nginx + zypper -n install curl libxml2 bash gettext shadow nginx awk SHELL [ "/bin/bash", "-o", "pipefail", "-c" ] @@ -21,11 +21,13 @@ RUN mkdir -p web/dist WORKDIR /web COPY --from=builder /web/dist /web/dist -COPY --from=builder /web/nginx.conf.template /etc/nginx/nginx.conf.template +COPY nginx.conf.template /etc/nginx/nginx.conf.template +COPY entrypoint.sh /entrypoint.sh EXPOSE 8000 ENV LONGHORN_MANAGER_IP http://localhost:9500 ENV LONGHORN_UI_PORT 8000 +ENV LONGHORN_NAMESPACE longhorn-system RUN mkdir -p /var/config/nginx/ \ && cp -r /etc/nginx/* /var/config/nginx/ \ @@ -35,4 +37,4 @@ RUN mkdir -p /var/config/nginx/ \ # Use the uid of the default user (nginx) from the installed nginx package USER 499 -CMD ["/bin/bash", "-c", "envsubst '${LONGHORN_MANAGER_IP},${LONGHORN_UI_PORT}' < /etc/nginx/nginx.conf.template > /var/config/nginx/nginx.conf && nginx -c /var/config/nginx/nginx.conf -g 'daemon off;'"] +ENTRYPOINT ["/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 000000000..2cf07a411 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +NAMESERVER_IP="$(grep -E '^nameserver' /etc/resolv.conf | head -n 1 | awk '{print $2}')" +LONGHORN_NAMESPACE_DOMAIN="$(grep -E '^search' /etc/resolv.conf | head -n 1 | awk '{print $2}')" + +export NAMESERVER_IP +export LONGHORN_NAMESPACE_DOMAIN + +envsubst '${LONGHORN_MANAGER_IP},${LONGHORN_UI_PORT},${LONGHORN_NAMESPACE_DOMAIN},${NAMESERVER_IP}' \ + < /etc/nginx/nginx.conf.template \ + > /var/config/nginx/nginx.conf + +nginx -c /var/config/nginx/nginx.conf diff --git a/nginx.conf.template b/nginx.conf.template index cb45f62b1..ba6f938dc 100644 --- a/nginx.conf.template +++ b/nginx.conf.template @@ -1,5 +1,11 @@ events { worker_connections 1024; } +daemon off; + +error_log /dev/stdout info; + http { + access_log /dev/stdout; + server { gzip on; gzip_min_length 1k; @@ -38,6 +44,11 @@ http { root /web/dist; } + location ~ ^/objectstore/([^/]+) { + resolver ${NAMESERVER_IP}; + proxy_pass http://$1.${LONGHORN_NAMESPACE_DOMAIN}:8080; + } + location / { root /web/dist; index index.html; diff --git a/src/routes/objectStorage/index.js b/src/routes/objectStorage/index.js index b1535e8eb..b9acded6c 100644 --- a/src/routes/objectStorage/index.js +++ b/src/routes/objectStorage/index.js @@ -183,7 +183,7 @@ class ObjectStore extends React.Component { }, administrateObjectStore: (record) => { if (record.name?.length) { - window.open(record.name, '_blank', 'noreferrer') + window.open(`objectstore/${record.name}/`, '_blank', 'noreferrer') } }, deleteObjectStore: (record) => {