Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Viewer deployment #2

Merged
merged 17 commits into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SERVICENAME=
CASLOGINURL=
CASVALIDATEURL=
COMPOSE_PROJECT_NAME=
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,8 @@ venv.bak/

# credential file
dj_local_conf.json
root/.one_params

# docker related file
docker-compose.yml
docker-compose-local.yml
ibl_docker_setup.sh

Expand Down
558 changes: 558 additions & 0 deletions apache/http2.4.conf

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions apache/pni-apache.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM httpd:2.4

RUN apt-get update -y \
&& apt-get install -y libapache2-mod-auth-cas ca-certificates\
libssl-dev libapache2-mod-fcgid \
&& rm -rf /var/cache/apk/* \
&& mkdir /tmp/cas && chown www-data:www-data /tmp/cas

COPY ./http2.4.conf /usr/local/apache2/conf/httpd.conf

COPY pni-apache.Dockerfile /Dockerfile
24 changes: 24 additions & 0 deletions apache/sites/cas.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# mod_auth_cas is an Apache 2.0/2.2 compliant module that supports the
# CASv1 and CASv2 protocols
#
<IfModule !mod_ssl.c>
LoadModule ssl_module modules/mod_ssl.so
</IfModule>
LoadModule auth_cas_module /usr/lib/apache2/modules/mod_auth_cas.so
<IfModule mod_auth_cas.c>
CASVersion 2
CASDebug On
# Validate the authenticity of the login.goshen.edu SSL certificate by
# checking its chain of authority from the root CA.
#CASCertificatePath /etc/pki/tls/certs/
#CASValidateServer Off
CASValidateDepth 9
#CASCookiePath /var/lib/cas/
CASCookiePath /tmp/cas/
CASLoginURL ${CASLOGINURL}
CASValidateURL ${CASVALIDATEURL}
#CASProxyValidateURL ${CASPROXYVALIDATEURL}
CASTimeout 864000
CASIdleTimeout 864000
</IfModule>
32 changes: 32 additions & 0 deletions apache/sites/proxypass.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
ServerName ${SERVICEHOSTNAME}

<VirtualHost _default_:80>

<Location />

#SSLRequireSSL
#SSLProtocol all -SSLv2 -SSLv3
AuthType CAS
CASScope /

Require valid-user

</Location>

RequestHeader set X-Remote-User %{REMOTE_USER}s
#RequestHeader set Remote-User %{REMOTE_USER}s

ProxyPreserveHost On
ProxyPass /ws ws://flask-root:5000/ws
ProxyPassReverse /ws ws://flask-root:5000/ws

ProxyPass / http://flask-root:5000/
ProxyPassReverse / http://flask-root:5000/


#RewriteRule .* - [E=X-Proxy-REMOTE-USER:%{REMOTE_USER}]
#RequestHeader set X-Proxy-REMOTE-USER %{REMOTE_USER}



</VirtualHost>
39 changes: 39 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: '3'
services:
apache:
env_file:
- .env
build:
context: ./apache
dockerfile: 'pni-apache.Dockerfile'
networks:
- proxy
- default
volumes:
- './apache/sites:/usr/local/apache2/conf/sites/:ro'
labels:
- "traefik.enable=true"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-http.entrypoints=http"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-https.entrypoints=https"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-https.tls=true"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-https.tls.certresolver=letsencrypt-resolver"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-http.middlewares=${COMPOSE_PROJECT_NAME}-redirectscheme@docker"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-http.rule=Host(`${SERVICEHOSTNAME}`)"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-https.rule=Host(`${SERVICEHOSTNAME}`)"
- "traefik.http.middlewares.${COMPOSE_PROJECT_NAME}-redirectscheme.redirectscheme.scheme=https"
- "traefik.http.middlewares.${COMPOSE_PROJECT_NAME}-redirectscheme.redirectscheme.permanent=true"
- "traefik.http.services.${COMPOSE_PROJECT_NAME}.loadbalancer.server.port=80"
- "traefik.docker.network=proxy"
flask-root:
env_file:
- .env
build:
context: .
dockerfile: ./viewer/viewer.Dockerfile
expose:
- 5000


networks:
proxy:
external: true
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys

setup(
name='Princeton Data Viewer',
name='princeton-u19-data-viewer',
version='0.0.0',
description="Data Viewer for Princeton Data pipeline",
author='Shan Shen',
Expand Down
7 changes: 5 additions & 2 deletions viewer/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import datajoint as dj


def datajoint_dot():
from bokeh.models import Div
from bokeh.layouts import layout
Expand Down Expand Up @@ -41,7 +42,7 @@ def main():
description='Princeton U19 DataJoint Interface')
parser.add_argument('-p','--port',
type=int,
default=5900,
default=5000,
help='port for the bokeh server',
action='store')
parser.add_argument('-n','--num-proc',
Expand All @@ -67,7 +68,8 @@ def main():
os.environ['BOKEH_ALLOW_WS_ORIGIN']=','.join(['localhost:{0}',
'0.0.0.0:{0}',
'{1}:{0},{2}:{0}',
'{1}.princeton.edu:{0}']).format(
'{1}.princeton.edu:{0}',
'braincogs01.pni.princeton.edu']).format(
port, hostname, ipaddress)

server = Server({'/': bkapp},
Expand All @@ -83,3 +85,4 @@ def main():

if __name__ == '__main__':
main()

9 changes: 9 additions & 0 deletions viewer/viewer.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.7.6-slim-buster
RUN apt-get update && apt-get install -y openssh-server graphviz
COPY . /data_viewer
WORKDIR /data_viewer
RUN pip install --upgrade pip
RUN pip install -e /data_viewer
EXPOSE 5000
ENTRYPOINT [ "python" ]
CMD [ "/data_viewer/viewer/server.py" ]