mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-15 09:24:52 +03:00
Use nginx to serve media files if cloud provider is None
This commit is contained in:
parent
18b510d09a
commit
ebbdb16557
|
@ -29,7 +29,7 @@ production-ready Django projects quickly.
|
||||||
- Optional basic ASGI setup for Websockets
|
- Optional basic ASGI setup for Websockets
|
||||||
- Optional custom static build using Gulp or Webpack
|
- Optional custom static build using Gulp or Webpack
|
||||||
- Send emails via [Anymail](https://github.com/anymail/django-anymail) (using [Mailgun](http://www.mailgun.com/) by default or Amazon SES if AWS is selected cloud provider, but switchable)
|
- Send emails via [Anymail](https://github.com/anymail/django-anymail) (using [Mailgun](http://www.mailgun.com/) by default or Amazon SES if AWS is selected cloud provider, but switchable)
|
||||||
- Media storage using Amazon S3, Google Cloud Storage or Azure Storage
|
- Media storage using Amazon S3, Google Cloud Storage, Azure Storage or nginx
|
||||||
- Docker support using [docker-compose](https://github.com/docker/compose) for development and production (using [Traefik](https://traefik.io/) with [LetsEncrypt](https://letsencrypt.org/) support)
|
- Docker support using [docker-compose](https://github.com/docker/compose) for development and production (using [Traefik](https://traefik.io/) with [LetsEncrypt](https://letsencrypt.org/) support)
|
||||||
- [Procfile](https://devcenter.heroku.com/articles/procfile) for deploying to Heroku
|
- [Procfile](https://devcenter.heroku.com/articles/procfile) for deploying to Heroku
|
||||||
- Instructions for deploying to [PythonAnywhere](https://www.pythonanywhere.com/)
|
- Instructions for deploying to [PythonAnywhere](https://www.pythonanywhere.com/)
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
"AWS",
|
"AWS",
|
||||||
"GCP",
|
"GCP",
|
||||||
"Azure",
|
"Azure",
|
||||||
"nginx",
|
|
||||||
"None"
|
"None"
|
||||||
],
|
],
|
||||||
"mail_service": [
|
"mail_service": [
|
||||||
|
|
|
@ -492,10 +492,6 @@ def main():
|
||||||
)
|
)
|
||||||
|
|
||||||
if "{{ cookiecutter.cloud_provider }}" == "None":
|
if "{{ cookiecutter.cloud_provider }}" == "None":
|
||||||
print(
|
|
||||||
WARNING + "You chose not to use a cloud provider, "
|
|
||||||
"media files won't be served in production." + TERMINATOR
|
|
||||||
)
|
|
||||||
remove_storages_module()
|
remove_storages_module()
|
||||||
|
|
||||||
if "{{ cookiecutter.use_celery }}".lower() == "n":
|
if "{{ cookiecutter.use_celery }}".lower() == "n":
|
||||||
|
|
|
@ -57,7 +57,7 @@ http:
|
||||||
# https://docs.traefik.io/master/routing/routers/#certresolver
|
# https://docs.traefik.io/master/routing/routers/#certresolver
|
||||||
certResolver: letsencrypt
|
certResolver: letsencrypt
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if cookiecutter.cloud_provider == 'nginx' %}
|
{%- if cookiecutter.cloud_provider == 'None' %}
|
||||||
|
|
||||||
web-media-router:
|
web-media-router:
|
||||||
rule: "Host(`{{ cookiecutter.domain_name }}`) && PathPrefix(`/media/`)"
|
rule: "Host(`{{ cookiecutter.domain_name }}`) && PathPrefix(`/media/`)"
|
||||||
|
@ -89,7 +89,8 @@ http:
|
||||||
servers:
|
servers:
|
||||||
- url: http://flower:5555
|
- url: http://flower:5555
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if cookiecutter.cloud_provider == 'nginx' %}
|
{%- if cookiecutter.cloud_provider == 'None' %}
|
||||||
|
|
||||||
django-media:
|
django-media:
|
||||||
loadBalancer:
|
loadBalancer:
|
||||||
servers:
|
servers:
|
||||||
|
|
|
@ -64,7 +64,7 @@ SECURE_CONTENT_TYPE_NOSNIFF = env.bool(
|
||||||
"DJANGO_SECURE_CONTENT_TYPE_NOSNIFF", default=True
|
"DJANGO_SECURE_CONTENT_TYPE_NOSNIFF", default=True
|
||||||
)
|
)
|
||||||
|
|
||||||
{% if cookiecutter.cloud_provider != 'None' and cookiecutter.cloud_provider != 'nginx' -%}
|
{% if cookiecutter.cloud_provider != 'None' -%}
|
||||||
# STORAGES
|
# STORAGES
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# https://django-storages.readthedocs.io/en/latest/#installation
|
# https://django-storages.readthedocs.io/en/latest/#installation
|
||||||
|
|
|
@ -4,7 +4,7 @@ volumes:
|
||||||
production_postgres_data: {}
|
production_postgres_data: {}
|
||||||
production_postgres_data_backups: {}
|
production_postgres_data_backups: {}
|
||||||
production_traefik: {}
|
production_traefik: {}
|
||||||
{%- if cookiecutter.cloud_provider == 'nginx' %}
|
{%- if cookiecutter.cloud_provider == 'None' %}
|
||||||
production_django_media: {}
|
production_django_media: {}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ services:
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
image: {{ cookiecutter.project_slug }}_production_django
|
image: {{ cookiecutter.project_slug }}_production_django
|
||||||
{%- if cookiecutter.cloud_provider == 'nginx' %}
|
{%- if cookiecutter.cloud_provider == 'None' %}
|
||||||
volumes:
|
volumes:
|
||||||
- production_django_media:/app/{{ cookiecutter.project_slug }}/media
|
- production_django_media:/app/{{ cookiecutter.project_slug }}/media
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
@ -96,7 +96,7 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- production_postgres_data_backups:/backups:z
|
- production_postgres_data_backups:/backups:z
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if cookiecutter.cloud_provider == 'nginx' %}
|
{%- if cookiecutter.cloud_provider == 'None' %}
|
||||||
nginx:
|
nginx:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
|
|
Loading…
Reference in New Issue
Block a user