Skip to content

Commit f928fee

Browse files
demonstrate one-off jobs with django sample
1 parent 562d3e8 commit f928fee

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

samples/django-celery/app/command.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#!/bin/bash
22

3-
# Apply database migrations
4-
python manage.py migrate
5-
63
# Create superuser if not exists
74
python manage.py createsuperauto
85

samples/django-celery/compose.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ services:
1010
- POSTGRES_URL=postgres://postgres:${POSTGRES_PASSWORD}@database:5432/postgres
1111
depends_on:
1212
- database
13+
- migrate
1314
- broker
1415
ports:
1516
- mode: ingress
@@ -22,6 +23,19 @@ services:
2223
retries: 3
2324
start_period: 20s
2425

26+
migrate:
27+
restart: no
28+
build:
29+
context: ./app
30+
dockerfile: Dockerfile
31+
environment:
32+
- SECRET_KEY
33+
- REDIS_URL=redis://broker:6379/0
34+
- POSTGRES_URL=postgres://postgres:${POSTGRES_PASSWORD}@database:5432/postgres
35+
depends_on:
36+
- database
37+
command: python manage.py migrate
38+
2539
worker:
2640
restart: unless-stopped
2741
build:
@@ -37,6 +51,7 @@ services:
3751
depends_on:
3852
- database
3953
- broker
54+
- migrate
4055
command: celery -A django_celery worker --loglevel=info
4156

4257
database:

0 commit comments

Comments
 (0)