mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-08 14:04:52 +03:00
Remove caddy, add nginx-proxy
This commit is contained in:
parent
a40121afd6
commit
02756e0543
|
@ -46,7 +46,7 @@ Features
|
||||||
* Grunt build for compass and livereload
|
* Grunt build for compass and livereload
|
||||||
* Send emails via Anymail_ (using Mailgun_ by default, but switchable)
|
* Send emails via Anymail_ (using Mailgun_ by default, but switchable)
|
||||||
* Media storage using Amazon S3
|
* Media storage using Amazon S3
|
||||||
* Docker support using docker-compose_ for development and production (using Caddy_ with LetsEncrypt_ support)
|
* Docker support using docker-compose_ for development and production (using acme.sh_ with LetsEncrypt_ support)
|
||||||
* Procfile_ for deploying to Heroku
|
* Procfile_ for deploying to Heroku
|
||||||
* Instructions for deploying to PythonAnywhere_
|
* Instructions for deploying to PythonAnywhere_
|
||||||
* Run tests with unittest or py.test
|
* Run tests with unittest or py.test
|
||||||
|
@ -82,7 +82,7 @@ Optional Integrations
|
||||||
.. _docker-compose: https://github.com/docker/compose
|
.. _docker-compose: https://github.com/docker/compose
|
||||||
.. _Opbeat: https://opbeat.com/
|
.. _Opbeat: https://opbeat.com/
|
||||||
.. _PythonAnywhere: https://www.pythonanywhere.com/
|
.. _PythonAnywhere: https://www.pythonanywhere.com/
|
||||||
.. _Caddy: https://caddyserver.com/
|
.. _acme.sh: https://github.com/Neilpang/acme.sh
|
||||||
.. _LetsEncrypt: https://letsencrypt.org/
|
.. _LetsEncrypt: https://letsencrypt.org/
|
||||||
|
|
||||||
Constraints
|
Constraints
|
||||||
|
|
|
@ -17,7 +17,7 @@ of this application gets its configuration from. Notice how it provides configur
|
||||||
|
|
||||||
* `postgres` service that runs the database
|
* `postgres` service that runs the database
|
||||||
* `redis` for caching
|
* `redis` for caching
|
||||||
* `caddy` as webserver
|
* `nginx` as proxy webserver
|
||||||
* `django` is the Django project run by gunicorn
|
* `django` is the Django project run by gunicorn
|
||||||
|
|
||||||
If you chose the `use_celery` option, there are two more services:
|
If you chose the `use_celery` option, there are two more services:
|
||||||
|
@ -59,11 +59,12 @@ It is always better to deploy a site behind HTTPS and will become crucial as the
|
||||||
HTTPS is configured by default
|
HTTPS is configured by default
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
The Caddy webserver used in the default configuration will get you a valid certificate from Lets Encrypt and update it automatically. All you need to do to enable this is to make sure that your DNS records are pointing to the server Caddy runs on.
|
The nginx webserver used in the default configuration will get you a valid certificate from Lets Encrypt and update it automatically, using the `nginx-proxy` docker image.
|
||||||
|
|
||||||
You can read more about this here at `Automatic HTTPS`_ in the Caddy docs.
|
You can read more about this here at `Automated Nginx Reverse Proxy for Docker`_ and the `acme.sh`_ docs.
|
||||||
|
|
||||||
.. _Automatic HTTPS: https://caddyserver.com/docs/automatic-https
|
.. _Automated Nginx Reverse Proxy for Docker: http://jasonwilder.com/blog/2014/03/25/automated-nginx-reverse-proxy-for-docker/
|
||||||
|
.. _acme.sh: https://github.com/Neilpang/acme.sh
|
||||||
|
|
||||||
|
|
||||||
Optional: Postgres Data Volume Modifications
|
Optional: Postgres Data Volume Modifications
|
||||||
|
@ -108,7 +109,7 @@ If you want to scale your application, run::
|
||||||
docker-compose -f production.yml scale django=4
|
docker-compose -f production.yml scale django=4
|
||||||
docker-compose -f production.yml scale celeryworker=2
|
docker-compose -f production.yml scale celeryworker=2
|
||||||
|
|
||||||
.. warning:: Don't run the scale command on postgres, celerybeat, or caddy.
|
.. warning:: Don't run the scale command on postgres, celerybeat, or nginx-proxy.
|
||||||
|
|
||||||
If you have errors, you can always check your stack with `docker-compose`. Switch to your projects root directory and run::
|
If you have errors, you can always check your stack with `docker-compose`. Switch to your projects root directory and run::
|
||||||
|
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
www.{% raw %}{$DOMAIN_NAME}{% endraw %} {
|
|
||||||
redir https://{{cookiecutter.domain_name}}
|
|
||||||
}
|
|
||||||
|
|
||||||
{% raw %}{$DOMAIN_NAME}{% endraw %} {
|
|
||||||
proxy / django:5000 {
|
|
||||||
header_upstream Host {host}
|
|
||||||
header_upstream X-Real-IP {remote}
|
|
||||||
header_upstream X-Forwarded-Proto {scheme}
|
|
||||||
}
|
|
||||||
log stdout
|
|
||||||
errors stdout
|
|
||||||
gzip
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
FROM abiosoft/caddy:0.10.6
|
|
||||||
|
|
||||||
COPY ./compose/production/caddy/Caddyfile /etc/Caddyfile
|
|
|
@ -4,8 +4,8 @@ POSTGRES_PASSWORD=mysecretpass
|
||||||
POSTGRES_USER=postgresuser
|
POSTGRES_USER=postgresuser
|
||||||
CONN_MAX_AGE=
|
CONN_MAX_AGE=
|
||||||
|
|
||||||
# Domain name, used by caddy
|
# Domain name, used by nginx-proxy
|
||||||
DOMAIN_NAME={{ cookiecutter.domain_name }}
|
VIRTUAL_HOST={{ cookiecutter.domain_name }}
|
||||||
|
|
||||||
# General settings
|
# General settings
|
||||||
# DJANGO_READ_DOT_ENV_FILE=True
|
# DJANGO_READ_DOT_ENV_FILE=True
|
||||||
|
|
|
@ -3,7 +3,6 @@ version: '2'
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data: {}
|
postgres_data: {}
|
||||||
postgres_backup: {}
|
postgres_backup: {}
|
||||||
caddy: {}
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
django:{% if cookiecutter.use_celery == 'y' %} &django{% endif %}
|
django:{% if cookiecutter.use_celery == 'y' %} &django{% endif %}
|
||||||
|
@ -14,7 +13,11 @@ services:
|
||||||
- postgres
|
- postgres
|
||||||
- redis
|
- redis
|
||||||
env_file: .env
|
env_file: .env
|
||||||
|
environment:
|
||||||
|
- ENABLE_ACME=true
|
||||||
command: /gunicorn.sh
|
command: /gunicorn.sh
|
||||||
|
expose:
|
||||||
|
- "5000"
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
build:
|
build:
|
||||||
|
@ -25,18 +28,18 @@ services:
|
||||||
- postgres_backup:/backups
|
- postgres_backup:/backups
|
||||||
env_file: .env
|
env_file: .env
|
||||||
|
|
||||||
caddy:
|
nginx-proxy:
|
||||||
build:
|
image: neilpang/nginx-proxy
|
||||||
context: .
|
|
||||||
dockerfile: ./compose/production/caddy/Dockerfile
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- django
|
- django
|
||||||
volumes:
|
|
||||||
- caddy:/root/.caddy
|
|
||||||
env_file: .env
|
|
||||||
ports:
|
ports:
|
||||||
- "0.0.0.0:80:80"
|
- "80:80"
|
||||||
- "0.0.0.0:443:443"
|
volumes:
|
||||||
|
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||||
|
- ./proxy/certs:/etc/nginx/certs
|
||||||
|
- ./proxy/acme:/acmecerts
|
||||||
|
- ./proxy/conf.d:/etc/nginx/conf.d
|
||||||
|
network_mode: "host"
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:3.0
|
image: redis:3.0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user