version: '3'

services:
  rabbitmq:
    image: rabbitmq:3-management
    container_name: rabbitmq
    ports:
      - "5672:5672"
      - "15672:15672"
    environment:
      RABBITMQ_DEFAULT_USER: guest
      RABBITMQ_DEFAULT_PASS: guest
    healthcheck:
      test: ["CMD", "rabbitmqctl", "status"]
      interval: 10s
      timeout: 5s
      retries: 5

  publisher:
    build:
      context: .
    container_name: publisher
    environment:
      - PYTHONUNBUFFERED=1
    command: python publisher.py
    depends_on:
      rabbitmq:
        condition: service_healthy

  consumer_1:
    build:
      context: .
    container_name: consumer_1
    environment:
      - PYTHONUNBUFFERED=1
    command: python consumer_1.py
    depends_on:
      rabbitmq:
        condition: service_healthy

  consumer_2:
    build:
      context: .
    container_name: consumer_2
    environment:
      - PYTHONUNBUFFERED=1
    command: python consumer_2.py
    depends_on:
      rabbitmq:
        condition: service_healthy