Configuration du build dev pour le projet agenda_culturel

This commit is contained in:
Jean-Marie Favreau 2023-09-16 15:15:05 +02:00
parent 016a00bf2f
commit 7e5305b47d
16 changed files with 19 additions and 18 deletions

View File

@ -2,7 +2,7 @@ include .env
export $(shell sed 's/=.*//' .env) export $(shell sed 's/=.*//' .env)
SHELL := /bin/sh SHELL := /bin/sh
PROJECTNAME ?= default_app_name PROJECTNAME ?= agenda_culturel
APP_NAME := $(PROJECTNAME) APP_NAME := $(PROJECTNAME)
BACKEND_APP_NAME := $(APP_NAME)-backend BACKEND_APP_NAME := $(APP_NAME)-backend

View File

@ -34,12 +34,12 @@ This quickstart provides an easy way to initiate a Django project using Docker.
1. **Clone the repository:** 1. **Clone the repository:**
```bash ```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:** 2. **Change directory into the project:**
```bash ```bash
cd django-docker-quickstart cd agenda-culturel
``` ```
3. **Copy the `env.example` file to `.env` and update the values as needed:** 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 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 ### Production Setup

View File

@ -10,6 +10,7 @@ services:
- APP_NAME=${APP_NAME} - APP_NAME=${APP_NAME}
- APP_HOST=${APP_HOST} - APP_HOST=${APP_HOST}
- APP_PORT=${APP_PORT} - APP_PORT=${APP_PORT}
- ALLOWED_HOSTS=${ALLOWED_HOSTS}
volumes: volumes:
- ./src:/usr/src/app/ - ./src:/usr/src/app/
- ./deployment/scripts:/app/deployment/scripts/ - ./deployment/scripts:/app/deployment/scripts/
@ -19,7 +20,7 @@ services:
depends_on: depends_on:
db: db:
condition: service_healthy condition: service_healthy
command: [ "/bin/sh", "/app/deployment/scripts/backend/start.sh" ] command: [ "/bin/bash", "/app/deployment/scripts/backend/start.sh" ]
db: db:
image: postgres:15.2-alpine image: postgres:15.2-alpine
@ -57,12 +58,12 @@ services:
- db - db
- redis - redis
- backend - backend
command: [ "/bin/sh", "/app/deployment/scripts/celery/start-worker.sh" ] command: [ "/bin/bash", "/app/deployment/scripts/celery/start-worker.sh" ]
celery-beat: celery-beat:
<<: *celery-worker <<: *celery-worker
container_name: "${APP_NAME}-celery-beat" 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: volumes:
postgres_data_dir: postgres_data_dir:

View File

@ -13,7 +13,7 @@ testpaths = [
] ]
pythonpath = [".", "src"] pythonpath = [".", "src"]
python_files = "tests.py test_*.py *_tests.py" python_files = "tests.py test_*.py *_tests.py"
DJANGO_SETTINGS_MODULE = "project_name.settings.test" DJANGO_SETTINGS_MODULE = "agenda_culturel.settings.test"
filterwarnings = [ filterwarnings = [
'ignore::DeprecationWarning:kombu.*:', 'ignore::DeprecationWarning:kombu.*:',
'ignore::DeprecationWarning:celery.*:', 'ignore::DeprecationWarning:celery.*:',

View File

@ -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``. 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 from django.core.asgi import get_asgi_application
APP_ENV = os.getenv("APP_ENV", "dev") 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() application = get_asgi_application()

View File

@ -5,9 +5,9 @@ from celery.schedules import crontab
# Set the default Django settings module for the 'celery' program. # Set the default Django settings module for the 'celery' program.
APP_ENV = os.getenv("APP_ENV", "dev") 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 # Using a string here means the worker doesn't have to serialize
# the configuration object to child processes. # the configuration object to child processes.

View File

@ -50,7 +50,7 @@ MIDDLEWARE = [
"django.middleware.clickjacking.XFrameOptionsMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware",
] ]
ROOT_URLCONF = "project_name.urls" ROOT_URLCONF = "agenda_culturel.urls"
TEMPLATES = [ TEMPLATES = [
{ {
@ -68,7 +68,7 @@ TEMPLATES = [
}, },
] ]
WSGI_APPLICATION = "project_name.wsgi.application" WSGI_APPLICATION = "agenda_culturel.wsgi.application"
# Database # Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases # https://docs.djangoproject.com/en/4.2/ref/settings/#databases

View File

@ -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``. 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 from django.core.wsgi import get_wsgi_application
APP_ENV = os.getenv("APP_ENV", "dev") 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() application = get_wsgi_application()

View File

@ -7,7 +7,7 @@ import sys
def main(): def main():
"""Run administrative tasks.""" """Run administrative tasks."""
APP_ENV = os.getenv("APP_ENV", "dev") 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: try:
from django.core.management import execute_from_command_line from django.core.management import execute_from_command_line
except ImportError as exc: except ImportError as exc:

View File

@ -1,4 +1,4 @@
from project_name.celery import app from agenda_culturel.celery import app
@app.task(bind=True, name="test_periodic_task") @app.task(bind=True, name="test_periodic_task")