Skip to content

Commit dbdcd2f

Browse files
authored
Merge pull request #14 from testdrivenio/feature/1.3.2
Feature/1.3.2
2 parents 4fb9eda + 2a56d9c commit dbdcd2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+120
-119
lines changed

compose/local/django/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
FROM python:3.11-slim-buster
1+
FROM python:3.12-slim-bullseye
22

33
ENV PYTHONUNBUFFERED 1
44
ENV PYTHONDONTWRITEBYTECODE 1
55

66
RUN apt-get update \
77
# dependencies for building Python packages
88
&& apt-get install -y build-essential \
9-
# psycopg2 dependencies
9+
# psycopg dependencies
1010
&& apt-get install -y libpq-dev \
1111
# Translations dependencies
1212
&& apt-get install -y gettext \

compose/local/django/celery/beat/start

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ set -o errexit
44
set -o nounset
55

66
rm -f './celerybeat.pid'
7-
celery -A django_celery_example beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
7+
celery -A django_celery_example beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler

compose/local/django/entrypoint

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ postgres_ready() {
1111
python << END
1212
import sys
1313
14-
import psycopg2
14+
import psycopg
1515
1616
try:
17-
psycopg2.connect(
17+
psycopg.connect(
1818
dbname="${SQL_DATABASE}",
1919
user="${SQL_USER}",
2020
password="${SQL_PASSWORD}",
2121
host="${SQL_HOST}",
2222
port="${SQL_PORT}",
2323
)
24-
except psycopg2.OperationalError:
24+
except psycopg.OperationalError:
2525
sys.exit(-1)
2626
sys.exit(0)
2727

compose/production/django/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
FROM python:3.11-slim-buster
1+
FROM python:3.12-slim-bullseye
22

33
ENV PYTHONUNBUFFERED 1
44

55
RUN apt-get update \
66
# dependencies for building Python packages
77
&& apt-get install -y build-essential netcat \
8-
# psycopg2 dependencies
8+
# psycopg dependencies
99
&& apt-get install -y libpq-dev \
1010
# Translations dependencies
1111
&& apt-get install -y gettext \

compose/production/django/celery/flower/start

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ exec celery -A django_celery_example \
1717
--broker="${CELERY_BROKER}" \
1818
flower \
1919
--basic_auth="${CELERY_FLOWER_USER}:${CELERY_FLOWER_PASSWORD}" \
20-
--persistent=1 --db=/app/flower_db/flower.db --state_save_interval=5000
20+
--persistent=1 --db=/app/flower_db/flower.db --state_save_interval=5000
21+

compose/production/django/celery/worker/start

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ set -o errexit
44
set -o pipefail
55
set -o nounset
66

7-
exec celery -A django_celery_example worker -l INFO
7+
exec celery -A django_celery_example worker -l INFO

compose/production/django/entrypoint

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ postgres_ready() {
88
python << END
99
import sys
1010
11-
import psycopg2
11+
import psycopg
1212
1313
try:
14-
psycopg2.connect(
14+
psycopg.connect(
1515
dbname="${SQL_DATABASE}",
1616
user="${SQL_USER}",
1717
password="${SQL_PASSWORD}",
1818
host="${SQL_HOST}",
1919
port="${SQL_PORT}",
2020
)
21-
except psycopg2.OperationalError:
21+
except psycopg.OperationalError:
2222
sys.exit(-1)
2323
sys.exit(0)
2424

compose/production/nginx/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM nginx:1.25.3-alpine
1+
FROM nginx:1.27.3-alpine
22

33
RUN rm /etc/nginx/conf.d/default.conf
4-
COPY nginx.conf /etc/nginx/conf.d
4+
COPY nginx.conf /etc/nginx/conf.d

compose/production/nginx/nginx.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ server {
5555
proxy_set_header Host $host;
5656
proxy_redirect off;
5757
}
58-
}
58+
}

db.sqlite3

128 KB
Binary file not shown.

django_celery_example/asgi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
It exposes the ASGI callable as a module-level variable named ``application``.
55
66
For more information on this file, see
7-
https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/
7+
https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/
88
"""
99

1010
import os

django_celery_example/celery.py

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import logging
66
from celery.signals import after_setup_logger
7+
78
from celery import Celery
89

910
from django.conf import settings
@@ -40,3 +41,4 @@ def on_after_setup_logger(logger, **kwargs):
4041
file_handler = logging.FileHandler('celery.log')
4142
file_handler.setFormatter(formatter)
4243
logger.addHandler(file_handler)
44+

django_celery_example/settings.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""
22
Django settings for django_celery_example project.
33
4-
Generated by 'django-admin startproject' using Django 5.0.
4+
Generated by 'django-admin startproject' using Django 5.1.5.
55
66
For more information on this file, see
7-
https://docs.djangoproject.com/en/5.0/topics/settings/
7+
https://docs.djangoproject.com/en/5.1/topics/settings/
88
99
For the full list of settings and their values, see
10-
https://docs.djangoproject.com/en/5.0/ref/settings/
10+
https://docs.djangoproject.com/en/5.1/ref/settings/
1111
"""
1212
import os
1313
from pathlib import Path
@@ -18,7 +18,7 @@
1818

1919

2020
# Quick-start development settings - unsuitable for production
21-
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
21+
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
2222

2323
# SECURITY WARNING: keep the secret key used in production secret!
2424
SECRET_KEY = os.environ.get("SECRET_KEY", "&nl8s430j^j8l*je+m&ys5dv#zoy)0a2+x1!m8hx290_sx&0gh")
@@ -39,9 +39,9 @@
3939
'django.contrib.sessions',
4040
'django.contrib.messages',
4141
'django.contrib.staticfiles',
42-
'polls',
4342
'channels',
4443
'django_celery_beat',
44+
'polls',
4545
'tdd',
4646
]
4747

@@ -76,8 +76,9 @@
7676
# WSGI_APPLICATION = 'django_celery_example.wsgi.application'
7777
ASGI_APPLICATION = 'django_celery_example.asgi.application'
7878

79+
7980
# Database
80-
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
81+
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
8182

8283
DATABASES = {
8384
"default": {
@@ -92,7 +93,7 @@
9293

9394

9495
# Password validation
95-
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
96+
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
9697

9798
AUTH_PASSWORD_VALIDATORS = [
9899
{
@@ -111,7 +112,7 @@
111112

112113

113114
# Internationalization
114-
# https://docs.djangoproject.com/en/5.0/topics/i18n/
115+
# https://docs.djangoproject.com/en/5.1/topics/i18n/
115116

116117
LANGUAGE_CODE = 'en-us'
117118

@@ -123,7 +124,7 @@
123124

124125

125126
# Static files (CSS, JavaScript, Images)
126-
# https://docs.djangoproject.com/en/5.0/howto/static-files/
127+
# https://docs.djangoproject.com/en/5.1/howto/static-files/
127128

128129
STATIC_URL = '/static/'
129130
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
@@ -132,7 +133,7 @@
132133
MEDIA_ROOT = os.path.join(BASE_DIR, 'mediafiles')
133134

134135
# Default primary key field type
135-
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
136+
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
136137

137138
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
138139

@@ -168,7 +169,6 @@
168169
Queue('low_priority'),
169170
)
170171

171-
172172
def route_task(name, args, kwargs, options, task=None, **kw):
173173
if ':' in name:
174174
queue, _ = name.split(':')

django_celery_example/urls.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
URL configuration for django_celery_example project.
33
44
The `urlpatterns` list routes URLs to views. For more information please see:
5-
https://docs.djangoproject.com/en/5.0/topics/http/urls/
5+
https://docs.djangoproject.com/en/5.1/topics/http/urls/
66
Examples:
77
Function views
88
1. Add an import: from my_app import views
@@ -23,3 +23,4 @@
2323
path('member/', include('tdd.urls')),
2424
path('', include('polls.urls')),
2525
]
26+

django_celery_example/wsgi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
It exposes the WSGI callable as a module-level variable named ``application``.
55
66
For more information on this file, see
7-
https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/
7+
https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/
88
"""
99

1010
import os

docker-compose.prod.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
- db
3131

3232
db:
33-
image: postgres:16-alpine
33+
image: postgres:17-alpine
3434
volumes:
3535
- postgres_data:/var/lib/postgresql/data/
3636
environment:
@@ -42,7 +42,7 @@ services:
4242
image: redis:7-alpine
4343

4444
rabbitmq:
45-
image: rabbitmq:3-management
45+
image: rabbitmq:4-management
4646
env_file:
4747
- ./.env/.prod-sample
4848

@@ -113,9 +113,9 @@ services:
113113
- /var/lib/docker/:/var/lib/docker:ro
114114
- /var/run/docker.sock:/var/run/docker.sock:ro
115115

116-
117116
volumes:
118117
postgres_data:
119118
staticfiles:
120119
mediafiles:
121-
flower_db:
120+
flower_db:
121+

polls/base_task.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ def _get_retry_countdown(self, task_func):
5353
full_jitter=retry_jitter
5454
)
5555

56-
return countdown
56+
return countdown

polls/consumers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ async def disconnect(self, close_code):
6464
async def update_task_status(self, event):
6565
data = event['data']
6666

67-
await self.send(text_data=json.dumps(data))
67+
await self.send(text_data=json.dumps(data))

polls/factories.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ class Meta:
1414
email = LazyAttribute(lambda o: '%[email protected]' % o.username)
1515
password = LazyAttribute(lambda o: make_password(o.username))
1616
first_name = Faker("first_name")
17-
last_name = Faker("last_name")
17+
last_name = Faker("last_name")
18+

polls/management/__init__.py

Whitespace-only changes.

polls/management/commands/__init__.py

Whitespace-only changes.

polls/management/commands/celery_worker.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ class Command(BaseCommand):
2020
def handle(self, *args, **options):
2121
print("Starting celery worker with autoreload...")
2222
autoreload.run_with_reloader(restart_celery)
23+

polls/routing.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55

66
urlpatterns = [
77
path('ws/task_status/<task_id>/', consumers.TaskStatusConsumer.as_asgi()),
8-
]
8+
]
9+

polls/tasks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def task_clear_session():
4848
from django.core.management import call_command
4949
call_command('clearsessions')
5050

51-
5251
@shared_task(name='default:dynamic_example_one')
5352
def dynamic_example_one():
5453
logger.info('Example One')
@@ -96,3 +95,4 @@ def task_transaction_test():
9695
logger.info(f'send email to {user.pk}')
9796
# this cause db rollback because of transaction.atomic
9897
raise Exception('test')
98+

0 commit comments

Comments
 (0)