From 69d300a2132f103162a5e98f68ae4256750ce527 Mon Sep 17 00:00:00 2001 From: danielhanrahan Date: Wed, 8 Sep 2021 17:55:13 +0100 Subject: Remove CLAMP_REST_URL variable from Docker image Remove redundant CLAMP_REST_URL environment variable Update README to remove references to CLAMP_REST_URL Group Dockerfile COPY commands to reduce image layers Issue-ID: POLICY-3639 Signed-off-by: danielhanrahan Change-Id: Ia6947a6681875167dfc63b0ffd19f7dc6faad6d4 --- README.md | 31 ++++++++------------ .../policy-gui-docker/src/main/docker/Dockerfile | 25 ++++++---------- .../src/main/docker/etc/nginx/http.d/default.conf | 33 ++++++++++++++++++++++ .../src/main/docker/etc/nginx/nginx.conf | 18 ++++++++++++ .../policy-gui-docker/src/main/docker/index.html | 14 +++++++++ .../src/main/docker/nginx/default.conf.template | 33 ---------------------- .../src/main/docker/nginx/index.html | 14 --------- .../src/main/docker/nginx/nginx.conf | 18 ------------ .../src/main/docker/policy-gui.sh | 1 - 9 files changed, 84 insertions(+), 103 deletions(-) create mode 100644 packages/policy-gui-docker/src/main/docker/etc/nginx/http.d/default.conf create mode 100644 packages/policy-gui-docker/src/main/docker/etc/nginx/nginx.conf create mode 100644 packages/policy-gui-docker/src/main/docker/index.html delete mode 100644 packages/policy-gui-docker/src/main/docker/nginx/default.conf.template delete mode 100644 packages/policy-gui-docker/src/main/docker/nginx/index.html delete mode 100644 packages/policy-gui-docker/src/main/docker/nginx/nginx.conf diff --git a/README.md b/README.md index 4bff635..feea0aa 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,11 @@ To build it using Maven 3, run: mvn clean install -P docker # Docker image -Maven produces a single docker image containing the policy GUIs. These are exposed on -the same port (2443) using different URLs: -- Apex Policy Editor: http://localhost:2443/apex-editor -- PDP Monitoring UI: http://localhost:2443/pdp-monitoring -- CLAMP Designer UI: http://localhost:2443/clamp +Maven produces a single docker image containing the policy GUIs. +These are exposed on the same port (2443) using different URLs: +- Apex Policy Editor: https://localhost:2443/apex-editor +- PDP Monitoring UI: https://localhost:2443/pdp-monitoring +- CLAMP Designer UI: https://localhost:2443/clamp ## Building You can use the following command to build the policy-gui docker image: @@ -25,23 +25,14 @@ mvn clean install -P docker ``` ## Deployment -Currently, the policy-gui docker image can be deployed with minimal configuration. As -the clamp backend is required to use the clamp GUI, you can use the CLAMP_REST_URL -environment variable to set its location. +Currently, the policy-gui docker image can be deployed without configuration. +For the GUI container to start correctly, the CLAMP backend +`policy-clamp-backend` should be started first. -By default, CLAMP_REST_URL is set to an invalid address (0.0.0.0), meaning the CLAMP GUI -will not work without specifying CLAMP_REST_URL. - -If running clamp as part of a docker network, where `policy-clamp-backend` is the CLAMP -backend, then CLAMP_REST_URL should be set to `https://policy-clamp-backend:8443`. - -If running clamp backend on localhost port 8443, the policy-gui docker image would be -started like this: +For local testing, if the CLAMP backend is running on localhost port 8443, +the policy-gui docker container can be started with: ``` -docker run -p 2443:2443 \ - --add-host host.docker.internal:host-gateway \ - --env CLAMP_REST_URL=https://host.docker.internal:8443 \ - onap/policy-gui +docker run -p 2443:2443 --add-host policy-clamp-backend:host-gateway onap/policy-gui ``` ## Client Credentials diff --git a/packages/policy-gui-docker/src/main/docker/Dockerfile b/packages/policy-gui-docker/src/main/docker/Dockerfile index 681a58d..0e8bcc2 100644 --- a/packages/policy-gui-docker/src/main/docker/Dockerfile +++ b/packages/policy-gui-docker/src/main/docker/Dockerfile @@ -26,30 +26,21 @@ ARG POLICY_LOGS=/var/log/onap/policy/gui ENV POLICY_LOGS=$POLICY_LOGS ENV POLICY_HOME=$POLICY_HOME/gui -ENV CLAMP_REST_URL=http://0.0.0.0 RUN mkdir -p $POLICY_HOME $POLICY_LOGS $POLICY_HOME/bin $POLICY_HOME/lib && \ chown -R policy:policy $POLICY_HOME $POLICY_LOGS && \ apk update && \ - apk add --no-cache gettext nginx + apk add --no-cache nginx -WORKDIR $POLICY_HOME -COPY policy-gui.sh ./bin/ -COPY /maven/gui-editor-apex-uber.jar ./lib/ -COPY /maven/gui-pdp-monitoring-uber.jar ./lib/ -COPY etc/ssl/clamp.key /etc/ssl/clamp.key -COPY etc/ssl/clamp.pem /etc/ssl/clamp.pem -COPY nginx/nginx.conf /etc/nginx/nginx.conf -COPY nginx/default.conf.template /etc/nginx/templates/default.conf.template -COPY nginx/index.html /usr/share/nginx/html/ -ADD /maven/gui-clamp-html.tar.gz /usr/share/nginx/html/ -ADD /maven/gui-pdp-monitoring-html.tar.gz /usr/share/nginx/html/ -RUN rm /etc/nginx/conf.d/default.conf && \ - ln -sf /dev/stdout /var/log/nginx/access.log && \ +COPY --chown=policy:policy etc/ /etc/ +COPY --chown=policy:policy policy-gui.sh $POLICY_HOME/bin/ +COPY --chown=policy:policy /maven/*.jar $POLICY_HOME/lib/ +ADD --chown=policy:policy index.html /maven/*-html.tar.gz /usr/share/nginx/html/ +RUN ln -sf /dev/stdout /var/log/nginx/access.log && \ ln -sf /dev/stderr /var/log/nginx/error.log && \ touch /var/run/nginx.pid && \ - chown -R policy:policy . /etc/nginx /usr/share/nginx /var/lib/nginx /var/log/nginx /var/run/nginx.pid && \ - chmod 755 bin/*.sh + chown -R policy:policy /etc/nginx /usr/share/nginx /var/lib/nginx /var/log/nginx /var/run/nginx.pid && \ + chmod 755 $POLICY_HOME/bin/*.sh USER policy WORKDIR $POLICY_HOME/bin diff --git a/packages/policy-gui-docker/src/main/docker/etc/nginx/http.d/default.conf b/packages/policy-gui-docker/src/main/docker/etc/nginx/http.d/default.conf new file mode 100644 index 0000000..2c589c4 --- /dev/null +++ b/packages/policy-gui-docker/src/main/docker/etc/nginx/http.d/default.conf @@ -0,0 +1,33 @@ +server { + listen 2443 default ssl; + ssl_protocols TLSv1.2; + ssl_certificate /etc/ssl/clamp.pem; + ssl_certificate_key /etc/ssl/clamp.key; + ssl_verify_client optional_no_ca; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ =404; + } + + location /clamp/restservices/clds/ { + proxy_pass https://policy-clamp-backend:8443/restservices/clds/; + proxy_set_header X-SSL-Cert $ssl_client_escaped_cert; + } + + location /pdp-monitoring/papservices/monitoring/ { + proxy_pass http://localhost:17999/papservices/monitoring/; + } + + location /apex-editor/ { + proxy_pass http://localhost:18989/; + proxy_set_header Host $host; + proxy_set_header If-Modified-Since $http_if_modified_since; + } + + location = /50x.html { + root /var/lib/nginx/html; + } + error_page 500 502 503 504 /50x.html; +} diff --git a/packages/policy-gui-docker/src/main/docker/etc/nginx/nginx.conf b/packages/policy-gui-docker/src/main/docker/etc/nginx/nginx.conf new file mode 100644 index 0000000..aac9bb6 --- /dev/null +++ b/packages/policy-gui-docker/src/main/docker/etc/nginx/nginx.conf @@ -0,0 +1,18 @@ +worker_processes 1; +pid /var/run/nginx.pid; +error_log /dev/stdout info; +events { +} +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + access_log /var/log/nginx/access.log main; + sendfile on; + #tcp_nopush on; + keepalive_timeout 65; + #gzip on; + include /etc/nginx/conf.d/*.conf; +} diff --git a/packages/policy-gui-docker/src/main/docker/index.html b/packages/policy-gui-docker/src/main/docker/index.html new file mode 100644 index 0000000..98742ae --- /dev/null +++ b/packages/policy-gui-docker/src/main/docker/index.html @@ -0,0 +1,14 @@ + + + + + ONAP Policy GUI + + + + + diff --git a/packages/policy-gui-docker/src/main/docker/nginx/default.conf.template b/packages/policy-gui-docker/src/main/docker/nginx/default.conf.template deleted file mode 100644 index 9b3348a..0000000 --- a/packages/policy-gui-docker/src/main/docker/nginx/default.conf.template +++ /dev/null @@ -1,33 +0,0 @@ -server { - listen 2443 default ssl; - ssl_protocols TLSv1.2; - ssl_certificate /etc/ssl/clamp.pem; - ssl_certificate_key /etc/ssl/clamp.key; - ssl_verify_client optional_no_ca; - - location / { - root /usr/share/nginx/html; - index index.html index.htm; - try_files $uri $uri/ =404; - } - - location /clamp/restservices/clds/ { - proxy_pass ${CLAMP_REST_URL}/restservices/clds/; - proxy_set_header X-SSL-Cert $ssl_client_escaped_cert; - } - - location /pdp-monitoring/papservices/monitoring/ { - proxy_pass http://localhost:17999/papservices/monitoring/; - } - - location /apex-editor/ { - proxy_pass http://localhost:18989/; - proxy_set_header Host $host; - proxy_set_header If-Modified-Since $http_if_modified_since; - } - - location = /50x.html { - root /var/lib/nginx/html; - } - error_page 500 502 503 504 /50x.html; -} diff --git a/packages/policy-gui-docker/src/main/docker/nginx/index.html b/packages/policy-gui-docker/src/main/docker/nginx/index.html deleted file mode 100644 index 98742ae..0000000 --- a/packages/policy-gui-docker/src/main/docker/nginx/index.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - ONAP Policy GUI - - - - - diff --git a/packages/policy-gui-docker/src/main/docker/nginx/nginx.conf b/packages/policy-gui-docker/src/main/docker/nginx/nginx.conf deleted file mode 100644 index aac9bb6..0000000 --- a/packages/policy-gui-docker/src/main/docker/nginx/nginx.conf +++ /dev/null @@ -1,18 +0,0 @@ -worker_processes 1; -pid /var/run/nginx.pid; -error_log /dev/stdout info; -events { -} -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - access_log /var/log/nginx/access.log main; - sendfile on; - #tcp_nopush on; - keepalive_timeout 65; - #gzip on; - include /etc/nginx/conf.d/*.conf; -} diff --git a/packages/policy-gui-docker/src/main/docker/policy-gui.sh b/packages/policy-gui-docker/src/main/docker/policy-gui.sh index bb2d9c9..050cbb7 100644 --- a/packages/policy-gui-docker/src/main/docker/policy-gui.sh +++ b/packages/policy-gui-docker/src/main/docker/policy-gui.sh @@ -30,7 +30,6 @@ echo "Starting gui-pdp-monitoring" $JAVA_HOME/bin/java -jar "$POLICY_HOME/lib/gui-pdp-monitoring-uber.jar" -p 17999 & echo "Starting nginx" -envsubst '${CLAMP_REST_URL}' < /etc/nginx/templates/default.conf.template > /etc/nginx/conf.d/default.conf nginx -g "daemon on;" wait -- cgit 1.2.3-korg