diff --git a/Dockerfile b/Dockerfile index 8b1cfbc3..15212424 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,43 +1,15 @@ # To run: docker run -v /path/to/wsgi.py:/var/www/peregrine/wsgi.py --name=peregrine -p 81:80 peregrine -# To check running container: docker exec -it peregrine /bin/bash +# To check running container: docker exec -it peregrine /bin/bash -FROM ubuntu:16.04 +FROM quay.io/cdis/py27base:pybase2-1.0.0 ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y --no-install-recommends \ - build-essential \ - curl \ - git \ - # dependency for cryptography - libffi-dev \ - # dependency for pyscopg2 - which is dependency for sqlalchemy postgres engine - libpq-dev \ - # dependency for cryptography - libssl-dev \ - libxml2-dev \ - libxslt1-dev \ - nginx \ - python2.7 \ - python-dev \ - python-pip \ - python-setuptools \ - sudo \ - vim \ - && python -m pip install --upgrade pip \ - && python -m pip install --upgrade setuptools \ - && python -m pip install --upgrade uwsgi \ - && mkdir /var/www/peregrine \ - && mkdir -p /var/www/.cache/Python-Eggs/ \ - && chown www-data -R /var/www/.cache/Python-Eggs/ \ - && mkdir /run/nginx/ \ - && mkdir -m 075 /var/run/gen3 \ - && chown root:www-data /var/run/gen3 +RUN mkdir /var/www/peregrine \ + && chown www-data /var/www/peregrine COPY . /peregrine COPY ./deployment/uwsgi/uwsgi.ini /etc/uwsgi/uwsgi.ini -COPY ./deployment/nginx/nginx.conf /etc/nginx/ -COPY ./deployment/nginx/uwsgi.conf /etc/nginx/sites-available/ WORKDIR /peregrine RUN pip install -r requirements.txt \ @@ -45,16 +17,11 @@ RUN pip install -r requirements.txt \ && VERSION=`git describe --always --tags` && echo "VERSION=\"${VERSION}\"" >>peregrine/version_data.py \ && cd /peregrine/src/gdcdictionary && DICTCOMMIT=`git rev-parse HEAD` && echo "DICTCOMMIT=\"${DICTCOMMIT}\"" >>/peregrine/peregrine/version_data.py \ && DICTVERSION=`git describe --always --tags` && echo "DICTVERSION=\"${DICTVERSION}\"" >>/peregrine/peregrine/version_data.py \ - && python setup.py install \ - && rm /etc/nginx/sites-enabled/default \ - && ln -s /etc/nginx/sites-available/uwsgi.conf /etc/nginx/sites-enabled/uwsgi.conf \ - && ln -sf /dev/stdout /var/log/nginx/access.log \ - && ln -sf /dev/stderr /var/log/nginx/error.log \ - && chown www-data /var/www/peregrine + && python setup.py install EXPOSE 80 -WORKDIR /var/www/peregrine +WORKDIR /var/www/peregrine -ENTRYPOINT [ "/bin/sh", "/peregrine/dockerrun.sh" ] +ENTRYPOINT [ "/bin/sh", "/dockerrun.sh" ] CMD [] diff --git a/deployment/nginx/nginx.conf b/deployment/nginx/nginx.conf deleted file mode 100644 index d24bf1bb..00000000 --- a/deployment/nginx/nginx.conf +++ /dev/null @@ -1,82 +0,0 @@ -user www-data; -worker_processes auto; -pid /run/nginx.pid; - -events { - worker_connections 100000; - # multi_accept on; -} - -http { - - ## - # Basic Settings - ## - - sendfile on; - tcp_nopush on; - tcp_nodelay on; - keepalive_timeout 65; - types_hash_max_size 2048; - # server_tokens off; - - # server_names_hash_bucket_size 64; - # server_name_in_redirect off; - - include /etc/nginx/mime.types; - default_type application/octet-stream; - - ## - # SSL Settings - ## - ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE - ssl_prefer_server_ciphers on; - - ## - # Logging Settings - ## - log_format json '{"gen3log": "nginx", ' - '"date_access": "$time_iso8601", ' - '"user_id": "$http_x_userid", ' - '"request_id": "$http_x_reqid", ' - '"session_id": "$http_x_sessionid", ' - '"visitor_id": "$http_x_visitorid", ' - '"network_client_ip": "$http_x_forwarded_for", ' - '"network_bytes_write": $body_bytes_sent, ' - '"http_response_time": "$request_time", ' - '"http_status_code": $status, ' - '"http_request": "$request_uri", ' - '"http_verb": "$request_method", ' - '"http_referer": "$http_referer", ' - '"http_useragent": "$http_user_agent", ' - '"message": "$request"}'; - - log_format aws '$http_x_forwarded_for - $http_x_userid [$time_local] ' - '"$request" $status $body_bytes_sent ' - '"$http_referer" "$http_user_agent"'; - - access_log /var/log/nginx/access.log json; - error_log /var/log/nginx/error.log; - - ## - # Gzip Settings - ## - - gzip on; - gzip_disable "msie6"; - - # gzip_vary on; - # gzip_proxied any; - # gzip_comp_level 6; - # gzip_buffers 16 8k; - # gzip_http_version 1.1; - # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; - - ## - # Virtual Host Configs - ## - - include /etc/nginx/conf.d/*.conf; - include /etc/nginx/sites-enabled/*; -} - diff --git a/deployment/nginx/uwsgi.conf b/deployment/nginx/uwsgi.conf deleted file mode 100644 index d89e4148..00000000 --- a/deployment/nginx/uwsgi.conf +++ /dev/null @@ -1,38 +0,0 @@ -server { - listen 80; - - location / { - uwsgi_param REMOTE_ADDR $http_x_forwarded_for if_not_empty; - uwsgi_param REMOTE_USER $http_x_userid if_not_empty; - uwsgi_param REMOTE_REQID $http_x_reqid if_not_empty; - uwsgi_param REMOTE_SESSIONID $http_x_sessionid if_not_empty; - uwsgi_param REMOTE_VISITORID $http_x_visitorid if_not_empty; - uwsgi_param GEN3_REQUEST_TIMESTAMP $msec; - uwsgi_param GEN3_TIMEOUT_SECONDS '45'; - - include uwsgi_params; - uwsgi_pass unix:/var/run/gen3/uwsgi.sock; - uwsgi_read_timeout 45s; - uwsgi_send_timeout 45s; - } - - location /_status { - include uwsgi_params; - uwsgi_param GEN3_REQUEST_TIMESTAMP $msec; - uwsgi_param GEN3_TIMEOUT_SECONDS $arg_timeout; - uwsgi_pass unix:/var/run/gen3/uwsgi.sock; - uwsgi_read_timeout 45s; - uwsgi_ignore_client_abort on; - access_log off; - } - - error_page 502 /502.html; - location /502.html { - return 504 '{"error": {"Request Timeout or Service Unavailable"}}'; - } - - error_page 504 /504.html; - location /504.html { - return 504 '{"error": {"Request Timeout"}}'; - } -} diff --git a/deployment/uwsgi/uwsgi.ini b/deployment/uwsgi/uwsgi.ini index a7658124..38a21a2a 100644 --- a/deployment/uwsgi/uwsgi.ini +++ b/deployment/uwsgi/uwsgi.ini @@ -5,13 +5,14 @@ buffer-size = 32768 chmod-socket = 666 master = true processes = 2 -harakiri-verbose = true +harakiki-verbose = 20 harakiri = 45 http-timeout = 45 socket-timeout = 45 worker-reload-mercy = 45 reload-mercy = 45 mule-reload-mercy = 45 +disable-logging = true wsgi-file=/var/www/peregrine/wsgi.py plugins = python vacuum = true diff --git a/dockerrun.sh b/dockerrun.sh deleted file mode 100755 index 4281cf4f..00000000 --- a/dockerrun.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/sh -# -# Note: base alpine Linux image may not include bash shell, -# and we probably want to move to that for service images, -# so just use bourn shell ... - -# -# Update certificate authority index - -# environment may have mounted more authorities -# - ex: /usr/local/share/ca-certificates/cdis-ca.crt into system bundle -# - -GEN3_DEBUG="${GEN3_DEBUG:-False}" -GEN3_SIDECAR="${GEN3_SIDECAR:-False}" -GEN3_DRYRUN="${GEN3_DRYRUN:-False}" - -run() { - if [ "$GEN3_DRYRUN" = True ]; then - echo "DRY RUN - not running: $@" - else - echo "Running $@" - "$@" - fi -} - -help() { - cat - <> ./wsgi.py -fi - -( - # Wait for nginx to create uwsgi.sock in a sub-process - count=0 - while [ ! -e /var/run/gen3/uwsgi.sock ] && [ $count -lt 10 ]; do - echo "... waiting for /var/run/gen3/uwsgi.sock to appear" - sleep 2 - count="$(($count+1))" - done - if [ ! -e /var/run/gen3/uwsgi.sock ]; then - echo "WARNING: /var/run/gen3/uwsgi.sock does not exist!!!" - fi - run uwsgi --ini /etc/uwsgi/uwsgi.ini -) & - -if [ "${GEN3_SIDECAR}" = False ]; then - run nginx -g 'daemon off;' -fi -wait diff --git a/requirements.txt b/requirements.txt index 7ef95060..3e36eab6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ defusedxml==0.5.0 -scipy==0.18.1 SurvivalPy==1.0.2 simplejson==3.8.1 stopit==1.1.1 @@ -35,7 +34,7 @@ Flask-SQLAlchemy-Session==1.1 -e git+https://git@github.com/uc-cdis/gdcdatamodel.git@1.3.6#egg=gdcdatamodel -e git+https://git@github.com/NCI-GDC/psqlgraph.git@5cddf49dd03a25bd4e553161d7ad7b9a6fe0ac0d#egg=psqlgraph -e git+https://git@github.com/NCI-GDC/cdisutils.git@8a8e599fdab5ade9bd8c586132d974a102e5d72d#egg=cdisutils -cdispyutils==0.2.12 +cdispyutils==0.2.13 -e git+https://git@github.com/uc-cdis/storage-client.git@0.1.1#egg=storageclient -e git+https://git@github.com/uc-cdis/dictionaryutils.git@2.0.4#egg=dictionaryutils -e git+https://git@github.com/uc-cdis/datamodelutils.git@0.4.0#egg=datamodelutils