diff --git a/Docker/Prod/docker-compose-cloudflare.yml b/Docker/Prod/docker-compose-cloudflare.yml index d6040c4..f31a2b5 100644 --- a/Docker/Prod/docker-compose-cloudflare.yml +++ b/Docker/Prod/docker-compose-cloudflare.yml @@ -19,10 +19,14 @@ services: context: ../../ dockerfile: Docker/Prod/Dockerfile command: > - bash -c "python3 src/manage.py makemigrations - && python3 src/manage.py migrate - && python3 src/manage.py collectstatic --noinput - && gunicorn --chdir src --bind 0.0.0.0:8000 config.wsgi" + bash -c "cd src + && python3 manage.py makemigrations + && echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ makemigrations completed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' + && python3 manage.py migrate + && echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ migrate completed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' + && python3 manage.py collectstatic --noinput + && echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ collectstatic completed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' + && gunicorn --bind 0.0.0.0:8000 config.wsgi" ports: - "8000:8000" depends_on: @@ -31,6 +35,32 @@ services: volumes: - static_volume:/django_static + celery-worker: + restart: always + build: + context: ../../ + dockerfile: Docker/Prod/Dockerfile + environment: + - DJANGO_SETTINGS_MODULE=config.settings.production + command: > + bash -c "cd src + && celery -A config worker -l info -f worker.log" + depends_on: + - django + + celery-beat: + restart: always + build: + context: ../../ + dockerfile: Docker/Prod/Dockerfile + environment: + - DJANGO_SETTINGS_MODULE=config.settings.production + command: > + bash -c "cd src + && celery -A config beat -l info -f beat.log" + depends_on: + - celery-worker + nginx: image: nginx ports: @@ -41,6 +71,7 @@ services: depends_on: - django +#TODO: add volume for celery logs volumes: dbdata: - static_volume: + static_volume: \ No newline at end of file diff --git a/Docker/Prod/docker-compose.yml b/Docker/Prod/docker-compose.yml index 39da0a2..85628b6 100644 --- a/Docker/Prod/docker-compose.yml +++ b/Docker/Prod/docker-compose.yml @@ -19,10 +19,14 @@ services: context: ../../ dockerfile: Docker/Prod/Dockerfile command: > - bash -c "python3 src/manage.py makemigrations - && python3 src/manage.py migrate - && python3 src/manage.py collectstatic --noinput - && gunicorn --chdir src --bind 0.0.0.0:8000 config.wsgi" + bash -c "cd src + && python3 manage.py makemigrations + && echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ makemigrations completed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' + && python3 manage.py migrate + && echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ migrate completed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' + && python3 manage.py collectstatic --noinput + && echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ collectstatic completed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' + && gunicorn --bind 0.0.0.0:8000 config.wsgi" ports: - "8000:8000" depends_on: @@ -31,6 +35,32 @@ services: volumes: - static_volume:/django_static + celery-worker: + restart: always + build: + context: ../../ + dockerfile: Docker/Prod/Dockerfile + environment: + - DJANGO_SETTINGS_MODULE=config.settings.production + command: > + bash -c "cd src + && celery -A config worker -l info -f worker.log" + depends_on: + - django + + celery-beat: + restart: always + build: + context: ../../ + dockerfile: Docker/Prod/Dockerfile + environment: + - DJANGO_SETTINGS_MODULE=config.settings.production + command: > + bash -c "cd src + && celery -A config beat -l info -f beat.log" + depends_on: + - celery-worker + nginx: image: nginx ports: @@ -52,6 +82,7 @@ services: - ../../config/certbot/www:/var/www/certbot entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'" +#TODO: add volume for celery logs volumes: dbdata: - static_volume: + static_volume: \ No newline at end of file diff --git a/src/config/asgi.py b/src/config/asgi.py index 9502b7f..a00b3b5 100644 --- a/src/config/asgi.py +++ b/src/config/asgi.py @@ -1,12 +1,3 @@ -""" -ASGI config for config project. - -It exposes the ASGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/ -""" - import os from django.core.asgi import get_asgi_application diff --git a/src/config/celery.py b/src/config/celery.py index fa0fedd..23cd088 100644 --- a/src/config/celery.py +++ b/src/config/celery.py @@ -1,9 +1,9 @@ -import os from celery import Celery from celery.schedules import crontab +# import os -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.development") +# os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production") app = Celery("django_celery") app.config_from_object("django.conf:settings", namespace="CELERY") app.autodiscover_tasks() diff --git a/src/config/settings/base.py b/src/config/settings/base.py index 3e9c0b0..0f86c51 100644 --- a/src/config/settings/base.py +++ b/src/config/settings/base.py @@ -92,4 +92,6 @@ EMAIL_HOST_PASSWORD = env("EMAIL_HOST_PASSWORD") EMAIL_HOST_USER = 'series.notification@gmail.com' EMAIL_PORT = 465 EMAIL_USE_SSL = True -DEFAULT_FROM_EMAIL = EMAIL_HOST_USER \ No newline at end of file +DEFAULT_FROM_EMAIL = EMAIL_HOST_USER + +CELERY_BROKER_URL = "amqp://guest:guest@rabbitmq:5672/" \ No newline at end of file diff --git a/src/config/settings/production.py b/src/config/settings/production.py index 206f9c9..aa9b041 100644 --- a/src/config/settings/production.py +++ b/src/config/settings/production.py @@ -22,6 +22,4 @@ STATIC_URL = '/django_static/' STATIC_ROOT = os.path.join(os.path.dirname(os.path.dirname(BASE_DIR)), 'django_static') STATICFILES_DIRS = [ BASE_DIR / 'static' -] - -CELERY_BROKER_URL = "amqp://guest:guest@rabbitmq:5672/" \ No newline at end of file +] \ No newline at end of file