# Docker Compose file for lesson OPS-250-L02. Synthetic data only; nothing here talks to a real service.
#   cp env.example .env        # then edit the values (the demo token is not a secret)
#   docker compose up -d --build mock-api
#   docker compose run --rm assistant poll
#   docker compose run --rm assistant report
#   docker compose down        # containers go away; the named volume assistant_data stays
services:
  mock-api:
    build: .
    image: barg-sabz-mock:1.0
    environment:
      MOCK_API_TOKEN: ${MOCK_API_TOKEN:?set MOCK_API_TOKEN in .env}
    ports:
      - "127.0.0.1:8787:8787"     # only this computer can reach it; never 0.0.0.0 on a server
    restart: unless-stopped

  assistant:
    image: barg-sabz-mock:1.0       # same image, different command
    depends_on:
      mock-api:
        condition: service_healthy  # wait for the HEALTHCHECK, not just for the container to start
    environment:
      MAIL_API_BASE: http://mock-api:8787          # service name = host name on the Compose network
      LLM_BASE_URL: http://mock-api:8787/v1
      MAIL_API_TOKEN: ${MOCK_API_TOKEN}
      LLM_API_KEY: ${MOCK_API_TOKEN}
      ASSISTANT_DB: /data/assistant.db
    volumes:
      - assistant_data:/data        # the processing ledger survives container removal
    entrypoint: ["python", "email_assistant.py"]
    healthcheck:
      disable: true                 # the image's HEALTHCHECK is for the API, not for this job
    profiles: ["job"]               # not started by "up"; run it with "docker compose run"

volumes:
  assistant_data:
