diff --git a/{{cookiecutter.package_name}}/Dockerfile b/{{cookiecutter.package_name}}/Dockerfile index bf18e4c..98f034c 100644 --- a/{{cookiecutter.package_name}}/Dockerfile +++ b/{{cookiecutter.package_name}}/Dockerfile @@ -2,7 +2,7 @@ # To check running container: docker exec -it {{ cookiecutter.package_name }} /bin/bash -FROM quay.io/cdis/python-nginx:1.3.0 +FROM quay.io/cdis/python-nginx:pybase3-1.0.0 ENV appname={{ cookiecutter.package_name }} @@ -18,8 +18,6 @@ RUN apk update \ COPY . /$appname COPY ./deployment/uwsgi/uwsgi.ini /etc/uwsgi/uwsgi.ini COPY ./deployment/uwsgi/wsgi.py /$appname/wsgi.py -COPY ./deployment/nginx/nginx.conf /etc/nginx/ -COPY ./deployment/nginx/uwsgi.conf /etc/nginx/conf.d/nginx.conf WORKDIR /$appname RUN python -m pip install --upgrade pip \ diff --git a/{{cookiecutter.package_name}}/deployment/nginx/nginx.conf b/{{cookiecutter.package_name}}/deployment/nginx/nginx.conf deleted file mode 100644 index def43dc..0000000 --- a/{{cookiecutter.package_name}}/deployment/nginx/nginx.conf +++ /dev/null @@ -1,57 +0,0 @@ -user nginx; -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 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 aws; - error_log /var/log/nginx/error.log; - - ## - # Gzip Settings - ## - - gzip on; - gzip_disable "msie6"; - - ## - # Virtual Host Configs - ## - - include /etc/nginx/conf.d/*.conf; - include /etc/nginx/sites-enabled/*; -} diff --git a/{{cookiecutter.package_name}}/deployment/nginx/uwsgi.conf b/{{cookiecutter.package_name}}/deployment/nginx/uwsgi.conf deleted file mode 100644 index 4b7514b..0000000 --- a/{{cookiecutter.package_name}}/deployment/nginx/uwsgi.conf +++ /dev/null @@ -1,34 +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; - - ## GEN3_REQUEST_TIMESTAMP and GEN3_TIMEOUT_SECONDS - # These two together aligns the HARAKIRI timeout in uWSGI with NGINX - # See also https://github.com/uc-cdis/cdis-python-utils#uwsgi - uwsgi_param GEN3_REQUEST_TIMESTAMP $msec; - uwsgi_param GEN3_TIMEOUT_SECONDS '20'; - - include uwsgi_params; - uwsgi_pass unix:/var/www/{{ cookiecutter.package_name }}/uwsgi.sock; - uwsgi_read_timeout 20s; - uwsgi_send_timeout 20s; - } - - location /_status { - include uwsgi_params; - uwsgi_pass unix:/var/www/{{ cookiecutter.package_name }}/uwsgi.sock; - uwsgi_read_timeout 20s; - uwsgi_param GEN3_REQUEST_TIMESTAMP $msec; - uwsgi_param GEN3_TIMEOUT_SECONDS $arg_timeout; - uwsgi_ignore_client_abort on; - access_log off; - } - - error_page 504 /504.html; - location /504.html { - return 504 '{"error": {"Request Timeout"}}'; - } -} diff --git a/{{cookiecutter.package_name}}/deployment/uwsgi/uwsgi.ini b/{{cookiecutter.package_name}}/deployment/uwsgi/uwsgi.ini index db8fe3c..151ff2c 100644 --- a/{{cookiecutter.package_name}}/deployment/uwsgi/uwsgi.ini +++ b/{{cookiecutter.package_name}}/deployment/uwsgi/uwsgi.ini @@ -1,7 +1,10 @@ [uwsgi] protocol = uwsgi -socket = /var/www/{{ cookiecutter.package_name }}/uwsgi.sock +socket = /var/run/gen3/uwsgi.sock buffer-size = 32768 +uid = nginx +gid = nginx +chown-socket = nginx:nginx chmod-socket = 666 master = true harakiri-verbose = 20 @@ -10,8 +13,6 @@ wsgi-file=/{{ cookiecutter.package_name }}/wsgi.py plugins = python3 vacuum = true chdir = /{{ cookiecutter.package_name }}/ -uid = nginx -gid = nginx pythonpath = /usr/local/lib/python3.6/site-packages/ diff --git a/{{cookiecutter.package_name}}/dockerrun.bash b/{{cookiecutter.package_name}}/dockerrun.bash deleted file mode 100755 index be1cdc2..0000000 --- a/{{cookiecutter.package_name}}/dockerrun.bash +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -cd /var/www/$appname - -# -# Update certificate authority index - -# environment may have mounted more authorities -# -update-ca-certificates -# -# Enable debug flag based on GEN3_DEBUG environment -# -if [[ -f ./wsgi.py && "$GEN3_DEBUG" == "True" ]]; then - echo -e "\napplication.debug=True\n" >> ./wsgi.py -fi - -( - # Wait for nginx to create uwsgi.sock - let count=0 - while [[ (! -e uwsgi.sock) && count -lt 10 ]]; do - sleep 2 - let count="$count+1" - done - if [[ ! -e uwsgi.sock ]]; then - echo "WARNING: /var/www/$appname/uwsgi.sock does not exist!!!" - fi - uwsgi --ini /etc/uwsgi/uwsgi.ini -) & - -nginx -g 'daemon off;'