From 933127f09706ddd257bbd5c126e4820a41c71541 Mon Sep 17 00:00:00 2001 From: Henry Jobst Date: Tue, 20 Dec 2022 12:44:22 +0100 Subject: [PATCH] exposed port for django docker container is now configurable --- README.md | 1 + cookiecutter.json | 1 + docs/project-generation-options.rst | 3 +++ {{cookiecutter.project_slug}}/compose/local/django/start | 2 +- {{cookiecutter.project_slug}}/local.yml | 2 +- 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 27fc6e0e1..4073bcb38 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ Answer the prompts with your own desired [options](http://cookiecutter-django.re windows [n]: n use_pycharm [n]: y use_docker [n]: n + docker_port [8000]: 8000 Select postgresql_version: 1 - 14 2 - 13 diff --git a/cookiecutter.json b/cookiecutter.json index 970411013..76a071664 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -17,6 +17,7 @@ "windows": "n", "use_pycharm": "n", "use_docker": "n", + "django_port": "8000", "postgresql_version": [ "14", "13", diff --git a/docs/project-generation-options.rst b/docs/project-generation-options.rst index 0560badd3..109d3309d 100644 --- a/docs/project-generation-options.rst +++ b/docs/project-generation-options.rst @@ -52,6 +52,9 @@ use_pycharm: use_docker: Indicates whether the project should be configured to use Docker_ and `Docker Compose`_. +docker_port: + External port for the django app when run as docker container + postgresql_version: Select a PostgreSQL_ version to use. The choices are: diff --git a/{{cookiecutter.project_slug}}/compose/local/django/start b/{{cookiecutter.project_slug}}/compose/local/django/start index ec57dc8e4..1d49dfcf8 100644 --- a/{{cookiecutter.project_slug}}/compose/local/django/start +++ b/{{cookiecutter.project_slug}}/compose/local/django/start @@ -9,5 +9,5 @@ python manage.py migrate {%- if cookiecutter.use_async == 'y' %} exec uvicorn config.asgi:application --host 0.0.0.0 --reload --reload-include '*.html' {%- else %} -exec python manage.py runserver_plus 0.0.0.0:8000 +exec python manage.py runserver_plus 0.0.0.0:{{ cookiecutter.django_port }} {%- endif %} diff --git a/{{cookiecutter.project_slug}}/local.yml b/{{cookiecutter.project_slug}}/local.yml index 38b9d77d3..48a33cb97 100644 --- a/{{cookiecutter.project_slug}}/local.yml +++ b/{{cookiecutter.project_slug}}/local.yml @@ -25,7 +25,7 @@ services: - ./.envs/.local/.django - ./.envs/.local/.postgres ports: - - "8000:8000" + - "{{ cookiecutter.django_port }}:8000" command: /start postgres: