Commit 35cb4e91 authored by Mathieu Courcelles's avatar Mathieu Courcelles

Merge branch 'dev' into 'master'

Removes nginx config and reduces gunicorn worker

See merge request !28
parents af994edf 2d738fab
Pipeline #36764815 passed with stages
in 3 minutes and 3 seconds
......@@ -10,6 +10,7 @@ before_script:
build:
script:
- docker pull $CI_REGISTRY_IMAGE:build || true
- docker build --cache-from $CI_REGISTRY_IMAGE:build --build-arg CI_COMMIT_SHA=$CI_COMMIT_SHA -t $CI_REGISTRY_IMAGE:build .
- docker push $CI_REGISTRY_IMAGE:build
stage: build
......
......@@ -23,7 +23,6 @@ COPY requirements/base.txt /usr/src/app/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
COPY services/gunicorn /usr/src/app/services/gunicorn
COPY services/nginx /usr/src/app/services/nginx
COPY init.sh /usr/src/app/
RUN chown www-data:www-data /usr/src/app \
......@@ -33,9 +32,6 @@ RUN chown www-data:www-data /usr/src/app \
COPY ./ /usr/src/app/src
# TODO-MC remove
RUN python /usr/src/app/src/manage.py collectstatic --noinput --settings=CLMSVault.settings.base
ARG CI_COMMIT_SHA
ENV GIT_SHA $CI_COMMIT_SHA
......
# Gunicorn configuration file
import multiprocessing
# import multiprocessing
bind = '0.0.0.0:8000'
workers = multiprocessing.cpu_count() * 2 + 1
#workers = multiprocessing.cpu_count() * 2 + 1
workers = 2
reload = False
timeout = 518400
max_requests = 50
......
# Run as a less privileged user for security reasons.
user nginx;
# How many worker threads to run;
# "auto" sets it to the number of CPU cores available in the system, and
# offers the best performance. Don't set it higher than the number of CPU
# cores if changing this parameter.
# The maximum number of connections for Nginx is calculated by:
# max_clients = worker_processes * worker_connections
worker_processes auto;
# Maximum open file descriptors per process;
# should be > worker_connections.
worker_rlimit_nofile 8192;
events {
# When you need > 8000 * cpu_cores connections, you start optimizing your OS,
# and this is probably the point at which you hire people who are smarter than
# you, as this is *a lot* of requests.
use epoll;
worker_connections 1024;
multi_accept on;
}
http {
include mime.types;
default_type application/octet-stream;
# Hide nginx version information.
server_tokens off;
open_file_cache max=1000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 5;
open_file_cache_errors off;
client_max_body_size 5000M;
proxy_connect_timeout 518400;
proxy_send_timeout 518400;
proxy_read_timeout 518400;
send_timeout 518400;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
# Enable Gzip
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_proxied any;
gzip_types text/javascript application/javascript text/css application/json application/xml text/plain;
gzip_static on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
gzip_vary on;
log_format json escape=json '{ "timestamp": "$time_iso8601", '
'"remote_address": "$remote_addr", '
'"x_forwarded_for": "$http_x_forwarded_for", '
'"request_method": "$request_method", '
'"url": "$uri", '
'"query": "$query_string", '
'"protocol": "$server_protocol", '
'"status": "$status", '
'"response_length": "$body_bytes_sent", '
'"referrer": "$http_referer", '
'"request_time": "$request_time", '
'"process_id": "$pid", '
'"user_agent": "$http_user_agent" }';
upstream app_server {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response
# for UNIX domain socket setups
#server unix:/usr/src/app/tmp/gunicorn.sock fail_timeout=0;
# for a TCP configuration
server localhost:8000 fail_timeout=0;
}
server {
# default server
listen 80;
access_log /dev/null;
error_log /dev/null warn;
location / {
return 444;
}
location /alive/ {
proxy_buffers 8 24k;
proxy_buffer_size 2k;
proxy_pass http://app_server;
proxy_set_header Host $http_host;
}
location /nginx-health {
return 200 "healthy\n";
}
}
server {
listen 80;
server_name HOST_REPLACE nginx;
access_log /dev/stdout json;
location /static/ {
alias /usr/src/app/static_root/;
expires 1h;
}
location /media/ {
alias /usr/src/app/media_root/;
expires 1h;
}
location / {
proxy_buffers 8 24k;
proxy_buffer_size 2k;
proxy_pass http://app_server;
proxy_set_header Host $http_host;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment