openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From csantan...@apache.org
Subject [incubator-openwhisk] branch master updated: Mount an optional html directory for serving static content. (#4259)
Date Mon, 11 Feb 2019 18:03:48 GMT
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 15ae5c4  Mount an optional html directory for serving static content. (#4259)
15ae5c4 is described below

commit 15ae5c4ae5dc9f84b1e9f5cfc05ffe6df94b53ca
Author: rodric rabbah <rodric@gmail.com>
AuthorDate: Mon Feb 11 13:03:41 2019 -0500

    Mount an optional html directory for serving static content. (#4259)
---
 ansible/group_vars/all                      |  1 +
 ansible/roles/nginx/tasks/deploy.yml        | 28 +++++++++++++++++++++++++---
 ansible/roles/nginx/templates/nginx.conf.j2 | 24 ++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/ansible/group_vars/all b/ansible/group_vars/all
index b925259..077945e 100755
--- a/ansible/group_vars/all
+++ b/ansible/group_vars/all
@@ -203,6 +203,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/nginx/tasks/deploy.yml b/ansible/roles/nginx/tasks/deploy.yml
index 418d228..545f812 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,9 @@
     recreate: true
     restart_policy: "{{ docker.restart.policy }}"
     hostname: "nginx"
-    volumes:
-      - "{{ whisk_logs_dir }}/nginx:/logs"
-      - "{{ nginx.confdir }}:/etc/nginx"
+    volumes: "{{ volumes }}"
+    expose:
+      - 8443
     ports:
       - "{{ nginx.port.http }}:80"
       - "{{ nginx.port.api }}:443"
diff --git a/ansible/roles/nginx/templates/nginx.conf.j2 b/ansible/roles/nginx/templates/nginx.conf.j2
index d351f84..cefea41 100644
--- a/ansible/roles/nginx/templates/nginx.conf.j2
+++ b/ansible/roles/nginx/templates/nginx.conf.j2
@@ -33,6 +33,24 @@ http {
     proxy_ssl_certificate_key /etc/nginx/{{ controller.ssl.key }};
 {% endif %}
 
+    gzip_static on;
+    types {
+        text/html                                        html htm shtml;
+        text/css                                         css;
+        text/xml                                         xml;
+        image/gif                                        gif;
+        image/jpeg                                       jpeg jpg;
+        image/png                                        png;
+        image/svg+xml                                    svg svgz;
+        image/x-icon                                     ico;
+        image/x-jng                                      jng;
+        image/x-ms-bmp                                   bmp;
+        application/javascript                           js;
+        application/json                                 json;
+        application/java-archive                         jar war ear;
+        application/pdf                                  pdf;
+    }
+
     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.
@@ -129,5 +147,11 @@ http {
         location /cli/go/download {
             rewrite /cli/go/download(.*) /cli$1 permanent;
         }
+
+{% if nginx.htmldir %}
+        location /ui {
+            alias /usr/share/nginx/html;
+        }
+{% endif %}
     }
 }


Mime
View raw message