version: '3.8'
services:
  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"

  db:
    image: postgres:15-alpine
    environment:
      POSTGRES_DB: trafficcms
      POSTGRES_USER: trafficuser
      POSTGRES_PASSWORD: trafficpass
    ports:
      - "5432:5432"
    volumes:
      - db_data:/var/lib/postgresql/data

  web:
    build:
      context: .
      dockerfile: Dockerfile.web
    environment:
      - FLASK_ENV=production
      - DATABASE_URL=postgresql://trafficuser:trafficpass@db:5432/trafficcms
      - REDIS_URL=redis://redis:6379/0
    depends_on:
      - db
      - redis
    ports:
      - "8000:8000"

  worker:
    build:
      context: .
      dockerfile: Dockerfile.worker
    environment:
      - DATABASE_URL=postgresql://trafficuser:trafficpass@db:5432/trafficcms
      - REDIS_URL=redis://redis:6379/0
    depends_on:
      - db
      - redis

volumes:
  db_data:
