From 3347fffe8ef971627272e5b84835db9bffe07ec1 Mon Sep 17 00:00:00 2001 From: ayurishchev Date: Wed, 7 Oct 2026 13:31:53 +0300 Subject: [PATCH] UI delivery, stage D: app-ui image on nginx-unprivileged (user nginx, port 8080) Co-Authored-By: Claude Sonnet 5.5 --- APP_UI/Dockerfile | 16 +++++++++------- APP_UI/default.conf.template | 2 +- deploy/allinone/entrypoint.sh | 3 ++- docker-compose.yml | 6 +++--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/APP_UI/Dockerfile b/APP_UI/Dockerfile index f36c782..a2929c9 100644 --- a/APP_UI/Dockerfile +++ b/APP_UI/Dockerfile @@ -7,15 +7,17 @@ COPY . . RUN npm run build # Stage 2: Serve -# nginx runs as root here: the image entrypoint renders the template into /etc/nginx/conf.d and port 80 -# is published by docker-compose. An unprivileged variant would change the port and the image. -FROM nginx:alpine +# nginx runs as the unprivileged user "nginx" (uid 101) and listens on 8080 (OVP_UI_PORT); docker-compose publishes +# it as the host port (OVPMON_HTTP_PORT, default 80). The image entrypoint renders the template into +# /etc/nginx/conf.d. Behind another proxy or Kubernetes: target port 8080. +FROM nginxinc/nginx-unprivileged:alpine COPY --from=build-stage /app/dist /usr/share/nginx/html COPY default.conf.template /etc/nginx/templates/default.conf.template # Validates OVP_CSP_CONNECT_EXTRA before the template is rendered (20-envsubst-on-templates.sh) COPY check-csp-connect-extra.sh /docker-entrypoint.d/15-check-csp-connect-extra.sh -# Extra connect-src origins of the CSP, separated by spaces (empty: same origin only). envsubst replaces -# only variables that are defined, so the default must exist -ENV OVP_CSP_CONNECT_EXTRA="" -EXPOSE 80 +# envsubst replaces only variables that are defined, so the defaults must exist. +# OVP_CSP_CONNECT_EXTRA: extra connect-src origins of the CSP, separated by spaces (empty: same origin only) +ENV OVP_UI_PORT=8080 \ + OVP_CSP_CONNECT_EXTRA="" +EXPOSE 8080 CMD ["nginx", "-g", "daemon off;"] diff --git a/APP_UI/default.conf.template b/APP_UI/default.conf.template index cf6fa71..2e57caf 100644 --- a/APP_UI/default.conf.template +++ b/APP_UI/default.conf.template @@ -1,5 +1,5 @@ server { - listen 80; + listen ${OVP_UI_PORT}; server_name localhost; server_tokens off; diff --git a/deploy/allinone/entrypoint.sh b/deploy/allinone/entrypoint.sh index 8c843b2..a110d37 100755 --- a/deploy/allinone/entrypoint.sh +++ b/deploy/allinone/entrypoint.sh @@ -84,7 +84,8 @@ OVP_CSP_CONNECT_EXTRA=$(printf '%s' "$OVP_CSP_CONNECT_EXTRA" | tr -s ' ') export OVP_CSP_CONNECT_EXTRA export OVP_API_HOST=127.0.0.1 OVP_API_PORT=5001 export OVP_PROFILER_HOST=127.0.0.1 OVP_PROFILER_PORT=8000 -envsubst '${OVP_API_HOST} ${OVP_API_PORT} ${OVP_PROFILER_HOST} ${OVP_PROFILER_PORT} ${OVP_CSP_CONNECT_EXTRA}' \ +export OVP_UI_PORT=80 +envsubst '${OVP_API_HOST} ${OVP_API_PORT} ${OVP_PROFILER_HOST} ${OVP_PROFILER_PORT} ${OVP_UI_PORT} ${OVP_CSP_CONNECT_EXTRA}' \ < /etc/ovpmon/default.conf.template > /etc/nginx/http.d/ovpmon.conf nginx -t || die "generated nginx configuration is invalid (see above)" diff --git a/docker-compose.yml b/docker-compose.yml index ee91068..4902bff 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,7 @@ services: container_name: ovp-ui restart: unless-stopped ports: - - "${OVPMON_HTTP_PORT:-80}:80" + - "${OVPMON_HTTP_PORT:-80}:8080" depends_on: - app-api - app-profiler @@ -29,8 +29,8 @@ services: # Extra connect-src origins of the CSP (API on another host), separated by spaces; empty = same origin only OVP_CSP_CONNECT_EXTRA: ${OVPMON_CSP_CONNECT_EXTRA:-} healthcheck: - # busybox wget exists in nginx:alpine - test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1/"] + # busybox wget exists in the nginx alpine image; nginx listens on 8080 inside (unprivileged, OVP_UI_PORT) + test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8080/"] interval: 30s timeout: 5s retries: 3