From 55928e137e67e8cce795a3ce921c80d8e9d0343c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tao=20Bror=20Bojl=C3=A9n?= Date: Wed, 20 Feb 2019 17:20:37 +0000 Subject: [PATCH 1/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7f0446c..75017ea 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# fediverse.space 🌐 +# fediverse.space 🌐 [![Netlify Status](https://api.netlify.com/api/v1/badges/ddc939c0-c12f-4e0e-8ca3-cf6abe8b9a5a/deploy-status)](https://app.netlify.com/sites/sharp-curran-4b66d3/deploys) The map of the fediverse that you always wanted. ## Requirements From 658f0558162c695f2a924abc72415e81b4a5fe84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tao=20Bror=20Bojl=C3=A9n?= Date: Wed, 20 Feb 2019 17:29:02 +0000 Subject: [PATCH 2/4] update README instructions --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 75017ea..f90d8a5 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,11 @@ The map of the fediverse that you always wanted. ## Commands ### Backend -- `python manage.py scrape` scrapes the entire fediverse -- `python manage.py build_graph` uses this information to lay out a graph + +After running the backend in Docker: + +- `docker-compose exec web python manage.py scrape` scrapes the entire fediverse +- `docker-compose exec web python manage.py build_graph` uses this information to lay out a graph To run in production, use `docker-compose -f docker-compose.yml -f docker-compose.production.yml` instead of just `docker-compose`. From 0227fa205021557259bee1fb8311eb9475085929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tao=20Bror=20Bojl=C3=A9n?= Date: Wed, 20 Feb 2019 18:14:05 +0000 Subject: [PATCH 3/4] set correct allowed_hosts --- backend/api/backend/settings/production.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/api/backend/settings/production.py b/backend/api/backend/settings/production.py index c4539a3..78f7130 100644 --- a/backend/api/backend/settings/production.py +++ b/backend/api/backend/settings/production.py @@ -2,7 +2,7 @@ from .base import * DEBUG = False -ALLOWED_HOSTS = ['fediverse.space', 'www.fediverse.space', 'staging.fediverse.space'] +ALLOWED_HOSTS = ['api.fediverse.space'] CORS_ORIGIN_WHITELIST = [ 'fediverse.space', From cd36e7902dbf7d0ad25ef33c9298528876a064e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tao=20Bojl=C3=A9n?= Date: Wed, 20 Feb 2019 20:04:07 +0000 Subject: [PATCH 4/4] merge --- backend/api/backend/settings/production.py | 3 +- config/nginx/conf.d/local.conf | 20 -------- docker-compose.production.yml | 57 ++++++++++++++++------ example.env | 3 ++ 4 files changed, 46 insertions(+), 37 deletions(-) delete mode 100644 config/nginx/conf.d/local.conf diff --git a/backend/api/backend/settings/production.py b/backend/api/backend/settings/production.py index c4539a3..975b4af 100644 --- a/backend/api/backend/settings/production.py +++ b/backend/api/backend/settings/production.py @@ -2,10 +2,9 @@ from .base import * DEBUG = False -ALLOWED_HOSTS = ['fediverse.space', 'www.fediverse.space', 'staging.fediverse.space'] +ALLOWED_HOSTS = ['api.fediverse.space'] CORS_ORIGIN_WHITELIST = [ 'fediverse.space', - 'www.fediverse.space', 'staging.fediverse.space' ] diff --git a/config/nginx/conf.d/local.conf b/config/nginx/conf.d/local.conf deleted file mode 100644 index 762dc7c..0000000 --- a/config/nginx/conf.d/local.conf +++ /dev/null @@ -1,20 +0,0 @@ -upstream app { - server unix:/var/gunicorn/.sock; -} - -server { - listen 80 default_server; - server_name localhost; - - location / { - allow all; - proxy_http_version 1.1; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - proxy_set_header X-Cluster-Client-Ip $remote_addr; - proxy_pass http://app; - } - - # Note that nginx doesn't serve any static files. -} - diff --git a/docker-compose.production.yml b/docker-compose.production.yml index d166321..6ade26a 100644 --- a/docker-compose.production.yml +++ b/docker-compose.production.yml @@ -1,9 +1,42 @@ version: '3' services: + nginx-proxy: + image: jwilder/nginx-proxy:alpine + restart: always + ports: + - "80:80" + - "443:443" + labels: + - com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy + volumes: + - gunicorn-socket:/var/gunicorn # to talk to Django + - /var/run/docker.sock:/tmp/docker.sock:ro # for nginx-proxy + - conf:/etc/nginx/conf.d + - vhost:/etc/nginx/vhost.d + - html:/usr/share/nginx/html + - certs:/etc/nginx/certs:ro + networks: + - nginx_network + letsencrypt: + image: jrcs/letsencrypt-nginx-proxy-companion + container_name: nginx-proxy-le + volumes: + - gunicorn-socket:/var/gunicorn + - conf:/etc/nginx/conf.d + - vhost:/etc/nginx/vhost.d + - html:/usr/share/nginx/html + - certs:/etc/nginx/certs:rw + - /var/run/docker.sock:/var/run/docker.sock:ro + networks: + - nginx_network + depends_on: + - nginx-proxy db: restart: always networks: - database_network + depends_on: + - letsencrypt web: restart: always volumes: @@ -15,24 +48,18 @@ services: environment: - ENVIRONMENT=production - DJANGO_SETTINGS_MODULE=backend.settings.production - nginx: - image: nginx:1.14 - # build: - # context: . - # dockerfile: Dockerfile.nginx - ports: - - "80:80" - volumes: - - gunicorn-socket:/var/gunicorn - - ./config/nginx/conf.d:/etc/nginx/conf.d - networks: - - nginx_network - depends_on: - - web + - VIRTUAL_HOST + - LETSENCRYPT_HOST + - LETSENCRYPT_EMAIL networks: database_network: driver: bridge nginx_network: driver: bridge volumes: - gunicorn-socket: + gunicorn-socket: + conf: + vhost: + html: + certs: + diff --git a/example.env b/example.env index 4abeff1..f6ee70c 100644 --- a/example.env +++ b/example.env @@ -3,3 +3,6 @@ POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres POSTGRES_DB=fediverse DJANGO_SETTINGS_MODULE=backend.settings.development +VIRTUAL_HOST=api.fediverse.space +LETSENCRYPT_HOST=api.fediverse.space +LETSENCRYPT_EMAIL=my@email.com