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

csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git


The following commit(s) were added to refs/heads/master by this push:
     new fb40eb6  Mount an optional html directory for serving static content. 
(#4252)
fb40eb6 is described below

commit fb40eb621f24fa0165654a9b039aa41a7928f609
Author: rodric rabbah <[email protected]>
AuthorDate: Wed Feb 6 21:57:52 2019 -0500

    Mount an optional html directory for serving static content. (#4252)
---
 ansible/group_vars/all                             |  1 +
 ansible/roles/cli-install/tasks/deploy.yml         |  2 +-
 ansible/roles/nginx/tasks/deploy.yml               | 26 +++++++++++++++++++---
 ansible/roles/nginx/templates/nginx.conf.j2        | 16 ++++++++-----
 .../test/scala/system/rest/GoCLINginxTests.scala   |  2 +-
 5 files changed, 36 insertions(+), 11 deletions(-)

diff --git a/ansible/group_vars/all b/ansible/group_vars/all
index a806200..27c8408 100755
--- a/ansible/group_vars/all
+++ b/ansible/group_vars/all
@@ -205,6 +205,7 @@ userLogs:
 
 nginx:
   confdir: "{{ config_root_dir }}/nginx"
+  htmldir: "{{ ui_path | default(false) }}"
   dir:
     become: "{{ nginx_dir_become | default(false) }}"
   version: "{{ nginx_version | default('1.13') }}"
diff --git a/ansible/roles/cli-install/tasks/deploy.yml 
b/ansible/roles/cli-install/tasks/deploy.yml
index 0d6589e..b25e7e2 100644
--- a/ansible/roles/cli-install/tasks/deploy.yml
+++ b/ansible/roles/cli-install/tasks/deploy.yml
@@ -5,7 +5,7 @@
 
 - name: grab the local CLI from the binaries unarchived into nginx
   get_url:
-    url: "https://{{host}}/cli/go/download/{{os}}/{{arch}}/{{wsk}}";
+    url: "https://{{host}}/cli/{{os}}/{{arch}}/{{wsk}}";
     dest: "{{ openwhisk_home }}/bin"
     mode: "0755"
     validate_certs: no
diff --git a/ansible/roles/nginx/tasks/deploy.yml 
b/ansible/roles/nginx/tasks/deploy.yml
index 705d462..53ee828 100644
--- a/ansible/roles/nginx/tasks/deploy.yml
+++ b/ansible/roles/nginx/tasks/deploy.yml
@@ -52,6 +52,28 @@
   retries: "{{ docker.pull.retries }}"
   delay: "{{ docker.pull.delay }}"
 
+- name: ensure html directory exists
+  stat:
+    path: "{{ nginx.htmldir }}"
+  register: nginx_html_dir_exists
+  when: nginx.htmldir
+
+- name: check if html directory exists
+  fail:
+    msg: html directory does not exist '{{ nginx.htmldir }}'
+  when: nginx.htmldir and not (nginx_html_dir_exists.stat.exists and 
nginx_html_dir_exists.stat.isdir)
+
+- name: configuration volumes to mount
+  set_fact:
+    volumes:
+      - "{{ whisk_logs_dir }}/nginx:/logs"
+      - "{{ nginx.confdir }}:/etc/nginx"
+
+- name: "optional html volume to mount"
+  set_fact:
+    volumes: "{{ volumes }} + [ '{{ nginx.htmldir }}:/usr/share/nginx/html' ]"
+  when: nginx.htmldir
+
 - name: (re)start nginx
   docker_container:
     name: nginx
@@ -60,9 +82,7 @@
     recreate: true
     restart_policy: "{{ docker.restart.policy }}"
     hostname: "nginx"
-    volumes:
-      - "{{ whisk_logs_dir }}/nginx:/logs"
-      - "{{ nginx.confdir }}:/etc/nginx"
+    volumes: "{{ volumes }}"
     expose:
       - 8443
     ports:
diff --git a/ansible/roles/nginx/templates/nginx.conf.j2 
b/ansible/roles/nginx/templates/nginx.conf.j2
index a86593f..e6f3b2e 100644
--- a/ansible/roles/nginx/templates/nginx.conf.j2
+++ b/ansible/roles/nginx/templates/nginx.conf.j2
@@ -33,6 +33,8 @@ http {
     proxy_ssl_certificate_key /etc/nginx/{{ controller.ssl.key }};
 {% endif %}
 
+    gzip_static on;
+
     upstream controllers {
         # fail_timeout: period of time the server will be considered 
unavailable
         # Mark the controller as unavailable for at least 60 seconds, to not 
get any requests during restart.
@@ -115,18 +117,20 @@ http {
         location /blackbox.tar.gz {
             return 301 
https://github.com/apache/incubator-openwhisk-runtime-docker/releases/download/sdk%400.1.0/blackbox-0.1.0.tar.gz;
         }
-        # leaving this for a while for clients out there to update to the new 
endpoint
-        location /blackbox-0.1.0.tar.gz {
-            return 301 /blackbox.tar.gz;
-        }
 
         location /OpenWhiskIOSStarterApp.zip {
             return 301 
https://github.com/apache/incubator-openwhisk-client-swift/releases/download/0.3.0/starterapp-0.3.0.zip;
         }
 
-        location /cli/go/download {
+        location /cli {
             autoindex on;
-            root /etc/nginx;
+            alias /etc/nginx/cli/go/download;
         }
+
+{% if nginx.htmldir %}
+        location /ui {
+            alias /usr/share/nginx/html;
+        }
+{% endif %}
     }
 }
diff --git a/tests/src/test/scala/system/rest/GoCLINginxTests.scala 
b/tests/src/test/scala/system/rest/GoCLINginxTests.scala
index 3621a4d..caf17ed 100644
--- a/tests/src/test/scala/system/rest/GoCLINginxTests.scala
+++ b/tests/src/test/scala/system/rest/GoCLINginxTests.scala
@@ -32,7 +32,7 @@ import DefaultJsonProtocol._
  */
 @RunWith(classOf[JUnitRunner])
 class GoCLINginxTests extends FlatSpec with Matchers with RestUtil {
-  val DownloadLinkGoCli = "cli/go/download"
+  val DownloadLinkGoCli = "cli"
   val ServiceURL = getServiceURL()
 
   it should s"respond to all files in root directory" in {

Reply via email to