Add Redis service and Celery configuration to Docker setup
- Introduced Redis service in both docker-compose files for production and development. - Updated web and celery services to use Redis as the broker and result backend. - Added necessary environment variables for Celery in settings.py. - Included new tasks and soil_data apps in Django settings and updated URL routing. - Updated requirements.txt to include Celery and Redis dependencies.
This commit is contained in:
+30
-1
@@ -31,10 +31,16 @@ services:
|
||||
db:
|
||||
condition: service_healthy
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: ai-redis
|
||||
ports:
|
||||
- "6380:6379" # host:container — سرویسها داخل شبکه از redis:6379 استفاده میکنند
|
||||
|
||||
web:
|
||||
build: .
|
||||
container_name: ai-web
|
||||
command: python manage.py runserver 0.0.0.0:8000
|
||||
command: ["python", "manage.py", "runserver", "0.0.0.0:8000"]
|
||||
volumes:
|
||||
- .:/app
|
||||
ports:
|
||||
@@ -43,9 +49,32 @@ services:
|
||||
- .env
|
||||
environment:
|
||||
DB_HOST: db
|
||||
CELERY_BROKER_URL: redis://redis:6379/0
|
||||
CELERY_RESULT_BACKEND: redis://redis:6379/0
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_started
|
||||
|
||||
celery:
|
||||
build: .
|
||||
container_name: ai-celery
|
||||
command: celery -A config worker -l info
|
||||
volumes:
|
||||
- .:/app
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
DB_HOST: db
|
||||
CELERY_BROKER_URL: redis://redis:6379/0
|
||||
CELERY_RESULT_BACKEND: redis://redis:6379/0
|
||||
SKIP_MIGRATE: "1"
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_started
|
||||
|
||||
volumes:
|
||||
ai_mysql_data:
|
||||
|
||||
Reference in New Issue
Block a user