From 1d802f93214461b0e5d7b7626b90212e84be581c Mon Sep 17 00:00:00 2001 From: Jefersonalves Date: Sun, 12 Nov 2017 10:52:54 -0200 Subject: [PATCH 1/9] Setting up nginx web server --- docker-compose.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index a817d61..63047a9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,10 @@ version: '3' services: + nginx: + image: nginx + ports: + - "8080:80" mongo: image: mongo ports: @@ -18,5 +22,6 @@ services: ports: - "8000:8000" depends_on: + - nginx - mongo - redis From d0dcfd1d5bce8505a45388f5fe8163f202d7f8f0 Mon Sep 17 00:00:00 2001 From: Jefersonalves Date: Sun, 12 Nov 2017 15:02:14 -0200 Subject: [PATCH 2/9] Create volume to share template files with nginx container --- docker-compose.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 63047a9..2a2f6e1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,8 @@ services: image: nginx ports: - "8080:80" + volumes: + - ./quero_cultura/templates/quero_cultura:/usr/share/nginx/html mongo: image: mongo ports: @@ -24,4 +26,4 @@ services: depends_on: - nginx - mongo - - redis + - redis \ No newline at end of file From e75d24cf6368863330c92655f91b27793af9c5b3 Mon Sep 17 00:00:00 2001 From: Jefersonalves Date: Sun, 12 Nov 2017 15:04:13 -0200 Subject: [PATCH 3/9] Create volume to expose the nginx configuration file --- docker-compose.yml | 1 + nginx.conf | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 nginx.conf diff --git a/docker-compose.yml b/docker-compose.yml index 2a2f6e1..10ddec8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,6 +7,7 @@ services: - "8080:80" volumes: - ./quero_cultura/templates/quero_cultura:/usr/share/nginx/html + - ./nginx.conf:/etc/nginx/nginx.conf mongo: image: mongo ports: diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..b66b276 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,32 @@ + +user nginx; +worker_processes 1; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + include /etc/nginx/conf.d/*.conf; +} \ No newline at end of file From 855ac4a8d0bdf386c01ec1b3cca2f8e440db02e6 Mon Sep 17 00:00:00 2001 From: pablodiegoss Date: Mon, 13 Nov 2017 20:24:58 -0200 Subject: [PATCH 4/9] Create Varnish Service --- Dockerfile | 12 ++++++++++++ boot.sh | 2 ++ docker-compose.yml | 8 ++++++-- varnish/default.vcl | 40 ++++++++++++++++++++++++++++++++++++++++ varnish/secret | 1 + 5 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 varnish/default.vcl create mode 100644 varnish/secret diff --git a/Dockerfile b/Dockerfile index b45a393..d4463c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,5 +3,17 @@ ENV PYTHONUNBUFFERED 1 RUN mkdir /code WORKDIR /code ADD requirements.txt /code/ + +RUN apt-get update && apt-get install -y varnish && apt-get install nano + +ENV VCL_CONFIG /etc/varnish/default.vcl +ENV CACHE_SIZE 256m +ENV VARNISHD_PARAMS -p default_ttl=3600 -p default_grace=3600 + + +RUN set -e + +EXPOSE 80 + RUN pip install -r requirements.txt ADD . /code/ diff --git a/boot.sh b/boot.sh index 6872a29..279e04c 100755 --- a/boot.sh +++ b/boot.sh @@ -2,6 +2,8 @@ python3 manage.py runserver 0.0.0.0:8000 & +service varnish restart & + sleep 3 rm celerybeat.pid & diff --git a/docker-compose.yml b/docker-compose.yml index 10ddec8..31b3b36 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,12 +19,16 @@ services: web: build: . command: chmod +x boot.sh + command: service varnish start command: ./boot.sh volumes: - .:/code + - ./varnish:/etc/varnish/ ports: - "8000:8000" + - "6081:6081" + - "6082:6082" + - "80:80" depends_on: - - nginx - mongo - - redis \ No newline at end of file + - redis diff --git a/varnish/default.vcl b/varnish/default.vcl new file mode 100644 index 0000000..ea9c099 --- /dev/null +++ b/varnish/default.vcl @@ -0,0 +1,40 @@ +# +# This is an example VCL file for Varnish. +# +# It does not do anything by default, delegating control to the +# builtin VCL. The builtin VCL is called when there is no explicit +# return statement. +# +# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/ +# and http://varnish-cache.org/trac/wiki/VCLExamples for more examples. + +# Marker to tell the VCL compiler that this VCL has been adapted to the +# new 4.0 format. +vcl 4.0; + +# Default backend definition. Set this to point to your content server. +backend default { + .host = "localhost"; + .port = "8000"; +} + +sub vcl_recv { + # Happens before we check if we have this in cache already. + # + # Typically you clean up the request here, removing cookies you don't need, + # rewriting the request, etc. +} + +sub vcl_backend_response { + # Happens after we have read the response headers from the backend. + # + # Here you clean the response headers, removing silly Set-Cookie headers + # and other mistakes your backend does. +} + +sub vcl_deliver { + # Happens when we have all the pieces we need, and are about to send the + # response to the client. + # + # You can do accounting or modifying the final object here. +} diff --git a/varnish/secret b/varnish/secret new file mode 100644 index 0000000..0e77b5b --- /dev/null +++ b/varnish/secret @@ -0,0 +1 @@ +0c97f720-582a-47b2-a056-4ed5ad5647b8 From ecf4ca464bb9f91d0a968efa5fdb1a3807898061 Mon Sep 17 00:00:00 2001 From: pablodiegoss Date: Mon, 13 Nov 2017 20:25:09 -0200 Subject: [PATCH 5/9] Remove Nginx Container --- docker-compose.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 31b3b36..c3177a6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,13 +1,6 @@ version: '3' services: - nginx: - image: nginx - ports: - - "8080:80" - volumes: - - ./quero_cultura/templates/quero_cultura:/usr/share/nginx/html - - ./nginx.conf:/etc/nginx/nginx.conf mongo: image: mongo ports: From b2058d8acf74ab7a7c1eba0587e4a9fbe4017db1 Mon Sep 17 00:00:00 2001 From: pablodiegoss Date: Mon, 13 Nov 2017 20:25:09 -0200 Subject: [PATCH 6/9] Revert "Remove Nginx Container" This reverts commit ecf4ca464bb9f91d0a968efa5fdb1a3807898061. --- docker-compose.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index c3177a6..31b3b36 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,13 @@ version: '3' services: + nginx: + image: nginx + ports: + - "8080:80" + volumes: + - ./quero_cultura/templates/quero_cultura:/usr/share/nginx/html + - ./nginx.conf:/etc/nginx/nginx.conf mongo: image: mongo ports: From e43e5a3a58d9ef93aee5bc203d36486970a4b3f5 Mon Sep 17 00:00:00 2001 From: pablodiegoss Date: Mon, 13 Nov 2017 20:24:58 -0200 Subject: [PATCH 7/9] Revert "Create Varnish Service" This reverts commit 855ac4a8d0bdf386c01ec1b3cca2f8e440db02e6. --- Dockerfile | 12 ------------ boot.sh | 2 -- docker-compose.yml | 8 ++------ varnish/default.vcl | 40 ---------------------------------------- varnish/secret | 1 - 5 files changed, 2 insertions(+), 61 deletions(-) delete mode 100644 varnish/default.vcl delete mode 100644 varnish/secret diff --git a/Dockerfile b/Dockerfile index d4463c4..b45a393 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,17 +3,5 @@ ENV PYTHONUNBUFFERED 1 RUN mkdir /code WORKDIR /code ADD requirements.txt /code/ - -RUN apt-get update && apt-get install -y varnish && apt-get install nano - -ENV VCL_CONFIG /etc/varnish/default.vcl -ENV CACHE_SIZE 256m -ENV VARNISHD_PARAMS -p default_ttl=3600 -p default_grace=3600 - - -RUN set -e - -EXPOSE 80 - RUN pip install -r requirements.txt ADD . /code/ diff --git a/boot.sh b/boot.sh index 279e04c..6872a29 100755 --- a/boot.sh +++ b/boot.sh @@ -2,8 +2,6 @@ python3 manage.py runserver 0.0.0.0:8000 & -service varnish restart & - sleep 3 rm celerybeat.pid & diff --git a/docker-compose.yml b/docker-compose.yml index 31b3b36..10ddec8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,16 +19,12 @@ services: web: build: . command: chmod +x boot.sh - command: service varnish start command: ./boot.sh volumes: - .:/code - - ./varnish:/etc/varnish/ ports: - "8000:8000" - - "6081:6081" - - "6082:6082" - - "80:80" depends_on: + - nginx - mongo - - redis + - redis \ No newline at end of file diff --git a/varnish/default.vcl b/varnish/default.vcl deleted file mode 100644 index ea9c099..0000000 --- a/varnish/default.vcl +++ /dev/null @@ -1,40 +0,0 @@ -# -# This is an example VCL file for Varnish. -# -# It does not do anything by default, delegating control to the -# builtin VCL. The builtin VCL is called when there is no explicit -# return statement. -# -# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/ -# and http://varnish-cache.org/trac/wiki/VCLExamples for more examples. - -# Marker to tell the VCL compiler that this VCL has been adapted to the -# new 4.0 format. -vcl 4.0; - -# Default backend definition. Set this to point to your content server. -backend default { - .host = "localhost"; - .port = "8000"; -} - -sub vcl_recv { - # Happens before we check if we have this in cache already. - # - # Typically you clean up the request here, removing cookies you don't need, - # rewriting the request, etc. -} - -sub vcl_backend_response { - # Happens after we have read the response headers from the backend. - # - # Here you clean the response headers, removing silly Set-Cookie headers - # and other mistakes your backend does. -} - -sub vcl_deliver { - # Happens when we have all the pieces we need, and are about to send the - # response to the client. - # - # You can do accounting or modifying the final object here. -} diff --git a/varnish/secret b/varnish/secret deleted file mode 100644 index 0e77b5b..0000000 --- a/varnish/secret +++ /dev/null @@ -1 +0,0 @@ -0c97f720-582a-47b2-a056-4ed5ad5647b8 From 5539fa5778d77ac92de4d9e045d5f7e567616a20 Mon Sep 17 00:00:00 2001 From: pablodiegoss Date: Fri, 1 Dec 2017 23:42:19 -0200 Subject: [PATCH 8/9] Change metabase port to 8080 --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0ff3839..2a32aa3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,7 +23,7 @@ services: volumes: - .:/code ports: - - "8000:8000" + - "80:8000" depends_on: - nginx - mongo @@ -45,7 +45,7 @@ services: metabase: image: metabase/metabase ports: - - "3000:3000" + - "8080:3000" environment: MB_DB_TYPE: postgres MB_DB_DBNAME: metabase From 59212f6d598f5e26a4e3f35c252673711a62e602 Mon Sep 17 00:00:00 2001 From: pablodiegoss Date: Fri, 1 Dec 2017 23:42:33 -0200 Subject: [PATCH 9/9] Remove Nginx container again --- docker-compose.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2a32aa3..e65ad02 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,13 +1,6 @@ version: '3' services: - nginx: - image: nginx - ports: - - "8080:80" - volumes: - - ./quero_cultura/templates/quero_cultura:/usr/share/nginx/html - - ./nginx.conf:/etc/nginx/nginx.conf mongo: image: mongo ports: @@ -25,7 +18,6 @@ services: ports: - "80:8000" depends_on: - - nginx - mongo - redis