From 7e5305b47db5579306fed4fc027c89652e0a4329 Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Sat, 16 Sep 2023 15:15:05 +0200 Subject: [PATCH] Configuration du build dev pour le projet agenda_culturel --- Makefile | 2 +- README.md | 6 +++--- docker-compose.yml | 7 ++++--- pyproject.toml | 2 +- src/{project_name => agenda_culturel}/__init__.py | 0 src/{project_name => agenda_culturel}/asgi.py | 4 ++-- src/{project_name => agenda_culturel}/celery.py | 4 ++-- src/{project_name => agenda_culturel}/settings/__init__.py | 0 src/{project_name => agenda_culturel}/settings/base.py | 4 ++-- src/{project_name => agenda_culturel}/settings/dev.py | 0 src/{project_name => agenda_culturel}/settings/prod.py | 0 src/{project_name => agenda_culturel}/settings/test.py | 0 src/{project_name => agenda_culturel}/urls.py | 0 src/{project_name => agenda_culturel}/wsgi.py | 4 ++-- src/manage.py | 2 +- src/test_app/tasks.py | 2 +- 16 files changed, 19 insertions(+), 18 deletions(-) rename src/{project_name => agenda_culturel}/__init__.py (100%) rename src/{project_name => agenda_culturel}/asgi.py (71%) rename src/{project_name => agenda_culturel}/celery.py (87%) rename src/{project_name => agenda_culturel}/settings/__init__.py (100%) rename src/{project_name => agenda_culturel}/settings/base.py (97%) rename src/{project_name => agenda_culturel}/settings/dev.py (100%) rename src/{project_name => agenda_culturel}/settings/prod.py (100%) rename src/{project_name => agenda_culturel}/settings/test.py (100%) rename src/{project_name => agenda_culturel}/urls.py (100%) rename src/{project_name => agenda_culturel}/wsgi.py (71%) diff --git a/Makefile b/Makefile index d9e41af..a686897 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ include .env export $(shell sed 's/=.*//' .env) SHELL := /bin/sh -PROJECTNAME ?= default_app_name +PROJECTNAME ?= agenda_culturel APP_NAME := $(PROJECTNAME) BACKEND_APP_NAME := $(APP_NAME)-backend diff --git a/README.md b/README.md index 0e9789e..feb348d 100644 --- a/README.md +++ b/README.md @@ -34,12 +34,12 @@ This quickstart provides an easy way to initiate a Django project using Docker. 1. **Clone the repository:** ```bash - git clone https://github.com/godd0t/django-docker-quickstart.git + git clone https://github.com/jmtrivial/agenda-culturel.git ``` 2. **Change directory into the project:** ```bash - cd django-docker-quickstart + cd agenda-culturel ``` 3. **Copy the `env.example` file to `.env` and update the values as needed:** @@ -91,7 +91,7 @@ This quickstart provides an easy way to initiate a Django project using Docker. make build-dev ``` -You can now access the application at http://localhost:8000. The development environment allows for immediate reflection of code changes. +You can now access the application at http://localhost:8008. The development environment allows for immediate reflection of code changes. ### Production Setup diff --git a/docker-compose.yml b/docker-compose.yml index 26cbf58..f792ccf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,6 +10,7 @@ services: - APP_NAME=${APP_NAME} - APP_HOST=${APP_HOST} - APP_PORT=${APP_PORT} + - ALLOWED_HOSTS=${ALLOWED_HOSTS} volumes: - ./src:/usr/src/app/ - ./deployment/scripts:/app/deployment/scripts/ @@ -19,7 +20,7 @@ services: depends_on: db: condition: service_healthy - command: [ "/bin/sh", "/app/deployment/scripts/backend/start.sh" ] + command: [ "/bin/bash", "/app/deployment/scripts/backend/start.sh" ] db: image: postgres:15.2-alpine @@ -57,12 +58,12 @@ services: - db - redis - backend - command: [ "/bin/sh", "/app/deployment/scripts/celery/start-worker.sh" ] + command: [ "/bin/bash", "/app/deployment/scripts/celery/start-worker.sh" ] celery-beat: <<: *celery-worker container_name: "${APP_NAME}-celery-beat" - command: [ "/bin/sh", "/app/deployment/scripts/celery/start-beat.sh" ] + command: [ "/bin/bash", "/app/deployment/scripts/celery/start-beat.sh" ] volumes: postgres_data_dir: diff --git a/pyproject.toml b/pyproject.toml index 4a89f7e..1bd3ab2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ testpaths = [ ] pythonpath = [".", "src"] python_files = "tests.py test_*.py *_tests.py" -DJANGO_SETTINGS_MODULE = "project_name.settings.test" +DJANGO_SETTINGS_MODULE = "agenda_culturel.settings.test" filterwarnings = [ 'ignore::DeprecationWarning:kombu.*:', 'ignore::DeprecationWarning:celery.*:', diff --git a/src/project_name/__init__.py b/src/agenda_culturel/__init__.py similarity index 100% rename from src/project_name/__init__.py rename to src/agenda_culturel/__init__.py diff --git a/src/project_name/asgi.py b/src/agenda_culturel/asgi.py similarity index 71% rename from src/project_name/asgi.py rename to src/agenda_culturel/asgi.py index 49a91cc..9892f02 100644 --- a/src/project_name/asgi.py +++ b/src/agenda_culturel/asgi.py @@ -1,5 +1,5 @@ """ -ASGI config for project_name project. +ASGI config for agenda_culturel project. It exposes the ASGI callable as a module-level variable named ``application``. @@ -12,6 +12,6 @@ import os from django.core.asgi import get_asgi_application APP_ENV = os.getenv("APP_ENV", "dev") -os.environ.setdefault("DJANGO_SETTINGS_MODULE", f"project_name.settings.{APP_ENV}") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", f"agenda_culturel.settings.{APP_ENV}") application = get_asgi_application() diff --git a/src/project_name/celery.py b/src/agenda_culturel/celery.py similarity index 87% rename from src/project_name/celery.py rename to src/agenda_culturel/celery.py index e2dc597..6137f4d 100644 --- a/src/project_name/celery.py +++ b/src/agenda_culturel/celery.py @@ -5,9 +5,9 @@ from celery.schedules import crontab # Set the default Django settings module for the 'celery' program. APP_ENV = os.getenv("APP_ENV", "dev") -os.environ.setdefault("DJANGO_SETTINGS_MODULE", f"project_name.settings.{APP_ENV}") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", f"agenda_culturel.settings.{APP_ENV}") -app = Celery("project_name") +app = Celery("agenda_culturel") # Using a string here means the worker doesn't have to serialize # the configuration object to child processes. diff --git a/src/project_name/settings/__init__.py b/src/agenda_culturel/settings/__init__.py similarity index 100% rename from src/project_name/settings/__init__.py rename to src/agenda_culturel/settings/__init__.py diff --git a/src/project_name/settings/base.py b/src/agenda_culturel/settings/base.py similarity index 97% rename from src/project_name/settings/base.py rename to src/agenda_culturel/settings/base.py index 6bc4b8c..260f28b 100644 --- a/src/project_name/settings/base.py +++ b/src/agenda_culturel/settings/base.py @@ -50,7 +50,7 @@ MIDDLEWARE = [ "django.middleware.clickjacking.XFrameOptionsMiddleware", ] -ROOT_URLCONF = "project_name.urls" +ROOT_URLCONF = "agenda_culturel.urls" TEMPLATES = [ { @@ -68,7 +68,7 @@ TEMPLATES = [ }, ] -WSGI_APPLICATION = "project_name.wsgi.application" +WSGI_APPLICATION = "agenda_culturel.wsgi.application" # Database # https://docs.djangoproject.com/en/4.2/ref/settings/#databases diff --git a/src/project_name/settings/dev.py b/src/agenda_culturel/settings/dev.py similarity index 100% rename from src/project_name/settings/dev.py rename to src/agenda_culturel/settings/dev.py diff --git a/src/project_name/settings/prod.py b/src/agenda_culturel/settings/prod.py similarity index 100% rename from src/project_name/settings/prod.py rename to src/agenda_culturel/settings/prod.py diff --git a/src/project_name/settings/test.py b/src/agenda_culturel/settings/test.py similarity index 100% rename from src/project_name/settings/test.py rename to src/agenda_culturel/settings/test.py diff --git a/src/project_name/urls.py b/src/agenda_culturel/urls.py similarity index 100% rename from src/project_name/urls.py rename to src/agenda_culturel/urls.py diff --git a/src/project_name/wsgi.py b/src/agenda_culturel/wsgi.py similarity index 71% rename from src/project_name/wsgi.py rename to src/agenda_culturel/wsgi.py index 2ba232f..9cb03b9 100644 --- a/src/project_name/wsgi.py +++ b/src/agenda_culturel/wsgi.py @@ -1,5 +1,5 @@ """ -WSGI config for project_name project. +WSGI config for agenda_culturel project. It exposes the WSGI callable as a module-level variable named ``application``. @@ -12,6 +12,6 @@ import os from django.core.wsgi import get_wsgi_application APP_ENV = os.getenv("APP_ENV", "dev") -os.environ.setdefault("DJANGO_SETTINGS_MODULE", f"project_name.settings.{APP_ENV}") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", f"agenda_culturel.settings.{APP_ENV}") application = get_wsgi_application() diff --git a/src/manage.py b/src/manage.py index e06b63e..0a2ded9 100755 --- a/src/manage.py +++ b/src/manage.py @@ -7,7 +7,7 @@ import sys def main(): """Run administrative tasks.""" APP_ENV = os.getenv("APP_ENV", "dev") - os.environ.setdefault("DJANGO_SETTINGS_MODULE", f"project_name.settings.{APP_ENV}") + os.environ.setdefault("DJANGO_SETTINGS_MODULE", f"agenda_culturel.settings.{APP_ENV}") try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/src/test_app/tasks.py b/src/test_app/tasks.py index f627d2f..3fd8409 100644 --- a/src/test_app/tasks.py +++ b/src/test_app/tasks.py @@ -1,4 +1,4 @@ -from project_name.celery import app +from agenda_culturel.celery import app @app.task(bind=True, name="test_periodic_task")