Merge branch 'develop/nginx_proxy' into 'master'
Put a reverse-proxy in front of the voila server to give us more flexibility Closes #10 See merge request cara/cara!10
This commit is contained in:
commit
9ffc0e35c1
12 changed files with 120 additions and 1 deletions
|
|
@ -25,3 +25,15 @@ trigger_build_on_openshift:
|
|||
- if: '$OPENSHIFT_BUILD_WEBHOOK_SECRET'
|
||||
script:
|
||||
- curl -X POST -k https://openshift.cern.ch:443/apis/build.openshift.io/v1/namespaces/cara/buildconfigs/cara-app/webhooks/${OPENSHIFT_BUILD_WEBHOOK_SECRET}/generic
|
||||
|
||||
|
||||
deploy_to_test:
|
||||
stage: deploy
|
||||
rules:
|
||||
- if: '$CI_MERGE_REQUEST_EVENT_TYPE == "detached"'
|
||||
when: never
|
||||
- if: '$OPENSHIFT_TEST_BUILD_WEBHOOK_SECRET'
|
||||
when: manual
|
||||
allow_failure: true
|
||||
script:
|
||||
- curl -X POST -k https://openshift-dev.cern.ch:443/apis/build.openshift.io/v1/namespaces/test-cara/buildconfigs/test-cara/webhooks/${OPENSHIFT_TEST_BUILD_WEBHOOK_SECRET}/generic
|
||||
|
|
|
|||
13
README.md
13
README.md
|
|
@ -7,6 +7,19 @@
|
|||
|
||||
## Development guide
|
||||
|
||||
### Building the docker image for local execution
|
||||
|
||||
**Simulate the docker build that takes place on openshift with:**
|
||||
|
||||
```
|
||||
s2i build file://$(pwd) --copy --context-dir=app-config/nginx/ centos/nginx-112-centos7 cara-nginx-app
|
||||
s2i build file://$(pwd) --copy --context-dir=./ centos/python-36-centos7 cara-voila-app
|
||||
cd app-config
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
Then visit localhost:8080.
|
||||
|
||||
### Setting up the application
|
||||
|
||||
The https://cern.ch/cara application is running on CERN's OpenShift platform. In order to set it up for the first time, we followed the documentation at https://cern.service-now.com/service-portal?id=kb_article&n=KB0004498. In particular we:
|
||||
|
|
|
|||
11
app-config/docker-compose.yml
Normal file
11
app-config/docker-compose.yml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
version: "3.8"
|
||||
services:
|
||||
cara-app:
|
||||
image: cara-voila-app
|
||||
links:
|
||||
- cara-router
|
||||
cara-router:
|
||||
image: cara-nginx-app
|
||||
ports:
|
||||
- "8080:8080"
|
||||
|
||||
1
app-config/nginx/404.html
Normal file
1
app-config/nginx/404.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
Page not found!
|
||||
1
app-config/nginx/calculator-static
Symbolic link
1
app-config/nginx/calculator-static
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../cara/apps/calculator/static
|
||||
3
app-config/nginx/index.html
Normal file
3
app-config/nginx/index.html
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<p>
|
||||
Welcome! Please see <a href="/expert-app">the expert application</a>.
|
||||
</p>
|
||||
73
app-config/nginx/nginx.conf
Normal file
73
app-config/nginx/nginx.conf
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
worker_processes auto;
|
||||
error_log /var/log/nginx/error.log;
|
||||
pid /run/nginx.pid;
|
||||
|
||||
include /usr/share/nginx/modules/*.conf;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
server {
|
||||
listen 8080 default_server;
|
||||
listen [::]:8080 default_server;
|
||||
server_name _;
|
||||
root /opt/app-root/src;
|
||||
|
||||
# Load configuration files for the default server block.
|
||||
include /opt/app-root/etc/nginx.default.d/*.conf;
|
||||
|
||||
large_client_header_buffers 4 16k;
|
||||
|
||||
location / {
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /40x.html {
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
}
|
||||
|
||||
location /voila-server/ {
|
||||
# cara-app is the name of the voila server in each of docker-compose,
|
||||
# test-cara.web.cern.ch and cara.web.cern.ch.
|
||||
proxy_pass http://cara-app:8080/voila-server/;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
rewrite ^/expert-app$ /voila-server/voila/render/cara.ipynb last;
|
||||
|
||||
# Give the static content of the calculator app a sensible name which is
|
||||
# consistent with the static directory of the calculator webserver used
|
||||
# for development.
|
||||
rewrite ^/calculator/static/(.*)$ /calculator-static/$1 last;
|
||||
|
||||
# Before implementing the nginx router we could access /voila/render/cara.ipynb.
|
||||
# Redirect this (and all other) URLs to the new scheme.
|
||||
rewrite ^/voila/(.*)$ /voila-server/voila/$1 redirect;
|
||||
}
|
||||
}
|
||||
3
app.sh
3
app.sh
|
|
@ -1 +1,2 @@
|
|||
voila app/ --port=8080
|
||||
voila app/ --port=8080 --no-browser --base_url=/voila-server/ --Voila.tornado_settings="{'allow_origin': '*'}"
|
||||
|
||||
|
|
|
|||
4
cara/apps/__init__.py
Normal file
4
cara/apps/__init__.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
from .expert import ExpertApplication
|
||||
|
||||
|
||||
__all__ = ['ExpertApplication']
|
||||
0
cara/apps/calculator/__init__.py
Normal file
0
cara/apps/calculator/__init__.py
Normal file
0
cara/apps/calculator/static/form.html
Normal file
0
cara/apps/calculator/static/form.html
Normal file
Loading…
Reference in a new issue