-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* basis celery settings * added lint to bootstrap test. Fixed imports * fix some comments * moved to rabbit * build with optional push * better optional push * simplified ci * removed redundant steps * Revert "moved to rabbit" This reverts commit 1dc88f5 * bump build-push-action * drop CELERY_TASK_ALWAYS_EAGER from .env.ci * fixed image name in ci * better compose * fixed toml-sort
- Loading branch information
Showing
11 changed files
with
133 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,8 +27,7 @@ RUN poetry export --format=requirements.txt > requirements.txt | |
# Base image with django dependecines | ||
# | ||
FROM python:${PYTHON_VERSION}-slim-bookworm as base | ||
LABEL maintainer="{{ cookiecutter.email }}" | ||
LABEL com.datadoghq.ad.logs='[{"service": "django", "source": "uwsgi"}]' | ||
LABEL maintainer="[email protected]" | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
ENV PYTHONUNBUFFERED 1 | ||
|
@@ -53,3 +52,25 @@ RUN ./manage.py collectstatic --noinput | |
|
||
FROM base as web | ||
CMD ./manage.py migrate && uwsgi --master --http :8000 --module app.wsgi --workers 2 --threads 2 --harakiri 25 --max-requests 1000 --log-x-forwarded-for | ||
|
||
|
||
FROM base as worker | ||
|
||
ENV _CELERY_APP=app.celery | ||
HEALTHCHECK --interval=15s --timeout=15s --start-period=5s --retries=3 \ | ||
CMD celery -A ${_CELERY_APP} inspect ping -d celery@$HOSTNAME | ||
|
||
CMD celery -A ${_CELERY_APP} worker -c ${CONCURENCY:-2} -n "celery@%h" --max-tasks-per-child ${MAX_REQUESTS_PER_CHILD:-50} --time-limit ${TIME_LIMIT:-900} --soft-time-limit ${SOFT_TIME_LIMIT:-45} | ||
|
||
|
||
FROM base as scheduler | ||
|
||
ENV _SCHEDULER_DB_PATH=/var/db/scheduler | ||
USER root | ||
RUN mkdir -p ${_SCHEDULER_DB_PATH} && chown nobody ${_SCHEDULER_DB_PATH} | ||
VOLUME ${_SCHEDULER_DB_PATH} | ||
USER nobody | ||
|
||
ENV _CELERY_APP=app.celery | ||
HEALTHCHECK NONE | ||
CMD celery -A ${_CELERY_APP} beat --pidfile=/tmp/celerybeat.pid --schedule=${_SCHEDULER_DB_PATH}/celerybeat-schedule.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,16 @@ build-backend = "poetry.core.masonry.api" | |
requires = ["poetry-core"] | ||
|
||
[tool.poetry] | ||
authors = ["{{ cookiecutter.author }} <{{ cookiecutter.email }}>"] | ||
description = "{{ cookiecutter.description }}" | ||
name = "{{ cookiecutter.name }}" | ||
authors = ["Fedor Borshev <[email protected]>"] | ||
description = "" | ||
name = "testproject" | ||
package-mode = false | ||
readme = "README.md" | ||
version = "0.0.0-dev" | ||
|
||
[tool.poetry.dependencies] | ||
bcrypt = "^4.1.3" | ||
celery = "5.4.0" | ||
django = "^4.2.14" | ||
django-axes = "^6.5.1" | ||
django-behaviors = "^0.5.1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
DATABASE_URL=postgres://postgres:@localhost:5432/postgres | ||
DEBUG=off | ||
SECRET_KEY={{ random_ascii_string(48, punctuation=True) }} | ||
|
||
CELERY_BROKER_URL=redis://localhost:6379/0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import os | ||
|
||
from celery import Celery | ||
from django.conf import settings | ||
|
||
__all__ = ["celery"] | ||
|
||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings") | ||
|
||
celery = Celery("app") | ||
celery.config_from_object("django.conf:settings", namespace="CELERY") | ||
celery.autodiscover_tasks(lambda: settings.INSTALLED_APPS) | ||
|
||
celery.conf.beat_schedule = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from app.conf.environ import env | ||
from app.conf.timezone import TIME_ZONE | ||
|
||
CELERY_BROKER_URL = env("CELERY_BROKER_URL", cast=str, default="redis://localhost:6379/0") | ||
CELERY_TASK_ALWAYS_EAGER = env("CELERY_TASK_ALWAYS_EAGER", cast=bool, default=env("DEBUG")) | ||
CELERY_TIMEZONE = TIME_ZONE | ||
CELERY_ENABLE_UTC = False | ||
CELERY_TASK_ACKS_LATE = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters