102 lines
2.2 KiB
YAML
102 lines
2.2 KiB
YAML
version: '3.8'
|
|
|
|
services:
|
|
# PostgreSQL database for the Django app
|
|
db:
|
|
image: postgres:15
|
|
environment:
|
|
POSTGRES_DB: postgres_handholder
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
ports:
|
|
- "5432:5432"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# Redis for Celery
|
|
redis:
|
|
image: redis:7-alpine
|
|
ports:
|
|
- "6379:6379"
|
|
volumes:
|
|
- redis_data:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# Django web application
|
|
web:
|
|
build: .
|
|
command: python manage.py runserver 0.0.0.0:8000
|
|
volumes:
|
|
- .:/app
|
|
- static_volume:/app/staticfiles
|
|
- media_volume:/app/media
|
|
ports:
|
|
- "8000:8000"
|
|
environment:
|
|
- DEBUG=True
|
|
- DB_HOST=db
|
|
- DB_NAME=postgres_handholder
|
|
- DB_USER=postgres
|
|
- DB_PASSWORD=postgres
|
|
- CELERY_BROKER_URL=redis://redis:6379/0
|
|
- CELERY_RESULT_BACKEND=redis://redis:6379/0
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
|
|
# Celery worker
|
|
celery:
|
|
build: .
|
|
command: celery -A postgres_handholder worker -l info
|
|
volumes:
|
|
- .:/app
|
|
environment:
|
|
- DEBUG=True
|
|
- DB_HOST=db
|
|
- DB_NAME=postgres_handholder
|
|
- DB_USER=postgres
|
|
- DB_PASSWORD=postgres
|
|
- CELERY_BROKER_URL=redis://redis:6379/0
|
|
- CELERY_RESULT_BACKEND=redis://redis:6379/0
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
|
|
# Celery beat scheduler
|
|
celery-beat:
|
|
build: .
|
|
command: celery -A postgres_handholder beat -l info
|
|
volumes:
|
|
- .:/app
|
|
environment:
|
|
- DEBUG=True
|
|
- DB_HOST=db
|
|
- DB_NAME=postgres_handholder
|
|
- DB_USER=postgres
|
|
- DB_PASSWORD=postgres
|
|
- CELERY_BROKER_URL=redis://redis:6379/0
|
|
- CELERY_RESULT_BACKEND=redis://redis:6379/0
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
|
|
volumes:
|
|
postgres_data:
|
|
redis_data:
|
|
static_volume:
|
|
media_volume: |