mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-15 17:34: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 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)
|
||||
- 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)
|
||||
- [Procfile](https://devcenter.heroku.com/articles/procfile) for deploying to Heroku
|
||||
- Instructions for deploying to [PythonAnywhere](https://www.pythonanywhere.com/)
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
"AWS",
|
||||
"GCP",
|
||||
"Azure",
|
||||
"nginx",
|
||||
"None"
|
||||
],
|
||||
"mail_service": [
|
||||
|
|
|
@ -492,10 +492,6 @@ def main():
|
|||
)
|
||||
|
||||
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()
|
||||
|
||||
if "{{ cookiecutter.use_celery }}".lower() == "n":
|
||||
|
|
|
@ -57,7 +57,7 @@ http:
|
|||
# https://docs.traefik.io/master/routing/routers/#certresolver
|
||||
certResolver: letsencrypt
|
||||
{%- endif %}
|
||||
{%- if cookiecutter.cloud_provider == 'nginx' %}
|
||||
{%- if cookiecutter.cloud_provider == 'None' %}
|
||||
|
||||
web-media-router:
|
||||
rule: "Host(`{{ cookiecutter.domain_name }}`) && PathPrefix(`/media/`)"
|
||||
|
@ -89,7 +89,8 @@ http:
|
|||
servers:
|
||||
- url: http://flower:5555
|
||||
{%- endif %}
|
||||
{%- if cookiecutter.cloud_provider == 'nginx' %}
|
||||
{%- if cookiecutter.cloud_provider == 'None' %}
|
||||
|
||||
django-media:
|
||||
loadBalancer:
|
||||
servers:
|
||||
|
|
|
@ -64,7 +64,7 @@ SECURE_CONTENT_TYPE_NOSNIFF = env.bool(
|
|||
"DJANGO_SECURE_CONTENT_TYPE_NOSNIFF", default=True
|
||||
)
|
||||
|
||||
{% if cookiecutter.cloud_provider != 'None' and cookiecutter.cloud_provider != 'nginx' -%}
|
||||
{% if cookiecutter.cloud_provider != 'None' -%}
|
||||
# STORAGES
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://django-storages.readthedocs.io/en/latest/#installation
|
||||
|
|
|
@ -4,7 +4,7 @@ volumes:
|
|||
production_postgres_data: {}
|
||||
production_postgres_data_backups: {}
|
||||
production_traefik: {}
|
||||
{%- if cookiecutter.cloud_provider == 'nginx' %}
|
||||
{%- if cookiecutter.cloud_provider == 'None' %}
|
||||
production_django_media: {}
|
||||
{%- endif %}
|
||||
|
||||
|
@ -27,7 +27,7 @@ services:
|
|||
{%- endif %}
|
||||
|
||||
image: {{ cookiecutter.project_slug }}_production_django
|
||||
{%- if cookiecutter.cloud_provider == 'nginx' %}
|
||||
{%- if cookiecutter.cloud_provider == 'None' %}
|
||||
volumes:
|
||||
- production_django_media:/app/{{ cookiecutter.project_slug }}/media
|
||||
{%- endif %}
|
||||
|
@ -96,7 +96,7 @@ services:
|
|||
volumes:
|
||||
- production_postgres_data_backups:/backups:z
|
||||
{%- endif %}
|
||||
{%- if cookiecutter.cloud_provider == 'nginx' %}
|
||||
{%- if cookiecutter.cloud_provider == 'None' %}
|
||||
nginx:
|
||||
build:
|
||||
context: .
|
||||
|
|
Loading…
Reference in New Issue
Block a user