From 55ecc1ca13d26b94fd88b693127bddaff989411a Mon Sep 17 00:00:00 2001 From: Ryan Noelk Date: Tue, 27 Mar 2018 20:58:35 +0200 Subject: [PATCH] Feature/use nginx to serve static (#2) * updating nginx to serve static direct, adding complied UI code to a docker volume * adding tests * removing Node config, adding build status --- .travis.yml | 12 ++++++++++++ README.md | 2 ++ default.conf | 21 ++++++++++++++------- start.sh | 1 - test.yml | 5 +++++ 5 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 .travis.yml create mode 100644 test.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d0ae68c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +sudo: required + +language: python + +python: + - "3.6" + +services: + - docker + +script: +- docker-compose -f test.yml -p test build nginx diff --git a/README.md b/README.md index 93733ef..842556e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # OpenEats Nginx Proxy Server +[![Build Status](https://travis-ci.org/open-eats/openeats-nginx.svg?branch=master)](https://travis-ci.org/open-eats/openeats-nginx) + This proxy server is meant as a way to easily link and serve the API and web app. Based on your environment file configuration, it will automatically bind the ports for the API and web app as well. See [the homepage](https://github.com/open-eats/OpenEats) for more information about OpenEats! diff --git a/default.conf b/default.conf index 16bb5c9..7ee4e30 100644 --- a/default.conf +++ b/default.conf @@ -4,18 +4,25 @@ upstream api { server api:API_PORT; } -upstream web { - ip_hash; - server web:NODE_PORT; -} - server { listen 80; server_name localhost; location / { - proxy_pass http://web/; - proxy_set_header Host $host; + root /var/www/html/openeats-static/public-ui; + try_files $uri $uri/ /index.html; + } + + location /static/ { + root /var/www/html/openeats-static/public-ui; + gzip on; + gzip_types text/plain text/xml text/css + text/comma-separated-values + text/javascript application/x-javascript + application/javascript + application/atom+xml; + + expires max; } location /api/ { diff --git a/start.sh b/start.sh index 9f1d628..9dd07d3 100755 --- a/start.sh +++ b/start.sh @@ -5,7 +5,6 @@ # Sed replace the API_PORT and NODE_PORT vars. sed -i "s/API_PORT/$API_PORT/g" /etc/nginx/conf.d/default.conf; -sed -i "s/NODE_PORT/$NODE_PORT/g" /etc/nginx/conf.d/default.conf; # Start the NGINX service. diff --git a/test.yml b/test.yml new file mode 100644 index 0000000..821362e --- /dev/null +++ b/test.yml @@ -0,0 +1,5 @@ +version: '2.3' +services: + nginx: + command: echo '' + build: .