diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b87c5097..7f4f0bfb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/README.md b/README.md index 0ba6d354..2c7cd501 100644 --- a/README.md +++ b/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: diff --git a/app-config/docker-compose.yml b/app-config/docker-compose.yml new file mode 100644 index 00000000..675b6829 --- /dev/null +++ b/app-config/docker-compose.yml @@ -0,0 +1,13 @@ +version: "3.8" +services: + cara-app: + image: cara-voila-app + # ports: + # - "8080:8081" + links: + - cara-router + cara-router: + image: cara-nginx-app + ports: + - "8080:8080" + diff --git a/app-config/nginx/index.html b/app-config/nginx/index.html new file mode 100644 index 00000000..264c7af2 --- /dev/null +++ b/app-config/nginx/index.html @@ -0,0 +1,3 @@ +

+Welcome! Please see the expert application. +

diff --git a/app-config/nginx/nginx.conf b/app-config/nginx/nginx.conf new file mode 100644 index 00000000..660f5616 --- /dev/null +++ b/app-config/nginx/nginx.conf @@ -0,0 +1,65 @@ +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/ { + 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; + # 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; + } +} \ No newline at end of file diff --git a/app.sh b/app.sh index ad938b68..e23f5afe 100755 --- a/app.sh +++ b/app.sh @@ -1 +1,2 @@ -voila app/ --port=8080 +voila app/ --port=8080 --no-browser --base_url=/voila-server/ --Voila.tornado_settings="{'allow_origin': '*'}" +