smart-line-bot / docker-compose.yml
Smiel2's picture
Initial commit
2eae977 verified
Raw
History Blame Contribute Delete
2.9 kB
version: '3.8'
services:
db:
image: postgres:15-alpine
container_name: demo_db
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: demo_project
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
redis:
image: redis:7-alpine
container_name: demo_redis
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
volumes:
- redis_data:/data
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
web:
build:
context: .
dockerfile: Dockerfile
container_name: demo_web
environment:
- ENVIRONMENT=development
- DEBUG=True
- DATABASE_URL=postgresql://postgres:postgres@db:5432/demo_project
- REDIS_URL=redis://redis:6379/0
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
ports:
- "8000:8000"
volumes:
- ./app:/app/app
- ./alembic:/app/alembic
- ./scripts:/app/scripts
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
restart: unless-stopped
worker:
build:
context: .
dockerfile: Dockerfile
container_name: demo_worker
environment:
- ENVIRONMENT=development
- DATABASE_URL=postgresql://postgres:postgres@db:5432/demo_project
- REDIS_URL=redis://redis:6379/0
- 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:
- ./app:/app/app
- ./alembic:/app/alembic
- ./scripts:/app/scripts
command: celery -A app.tasks.celery_app worker --loglevel=info --concurrency=2
restart: unless-stopped
beat:
build:
context: .
dockerfile: Dockerfile
container_name: demo_beat
environment:
- ENVIRONMENT=development
- DATABASE_URL=postgresql://postgres:postgres@db:5432/demo_project
- REDIS_URL=redis://redis:6379/0
- 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:
- ./app:/app/app
- ./alembic:/app/alembic
- ./scripts:/app/scripts
command: celery -A app.tasks.celery_app beat --loglevel=info
restart: unless-stopped
volumes:
postgres_data:
redis_data: