UI delivery, stage D: app-ui image on nginx-unprivileged (user nginx, port 8080)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
71ea4c5945
commit
3347fffe8e
4 files changed
+15
-12
No files matched your search
+9
-7
@@ -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;"]
|
||||
@@ -1,5 +1,5 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen ${OVP_UI_PORT};
|
||||
server_name localhost;
|
||||
server_tokens off;
|
||||
|
||||
|
||||
@@ -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)"
|
||||
|
||||
|
||||
+3
-3
@@ -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
|
||||
|
||||
Reference in new issue
Block a user