09e0c26c68
- 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.
81 lines
1.8 KiB
YAML
81 lines
1.8 KiB
YAML
# Development: volumes mount source so code updates apply without rebuild
|
|
name: ai
|
|
|
|
services:
|
|
db:
|
|
image: mysql:8.0
|
|
container_name: ai-db
|
|
environment:
|
|
MYSQL_DATABASE: ${DB_NAME:-ai}
|
|
MYSQL_USER: ${DB_USER:-ai}
|
|
MYSQL_PASSWORD: ${DB_PASSWORD:-changeme}
|
|
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-changeme}
|
|
volumes:
|
|
- ai_mysql_data:/var/lib/mysql
|
|
healthcheck:
|
|
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${DB_PASSWORD:-changeme}"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
phpmyadmin:
|
|
image: phpmyadmin:latest
|
|
container_name: ai-phpmyadmin
|
|
environment:
|
|
PMA_HOST: db
|
|
PMA_PORT: 3306
|
|
UPLOAD_LIMIT: 64M
|
|
ports:
|
|
- "8082:80"
|
|
depends_on:
|
|
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"]
|
|
volumes:
|
|
- .:/app
|
|
ports:
|
|
- "8020:8000"
|
|
env_file:
|
|
- .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:
|