---
services:
  fmt:
    platform: linux/amd64
    build:
      context: .
      target: unit-lint
    volumes:
      - ./src:/app/src
      - ./tests:/app/tests
      - ./dev:/app/dev
    entrypoint: []
    command:
      - sh
      - -c
      - "ruff check src tests dev --fix && ruff format src tests dev"
  moto-server:
    platform: linux/amd64
    image: motoserver/moto:5.1.22
    healthcheck:
      test:
        - CMD
        - python
        - -c
        - "import urllib.request; urllib.request.urlopen('http://localhost:5000/moto-api/').read()"
      interval: 1s
      timeout: 2s
      retries: 10
      start_period: 2s
  lint-and-test:
    platform: linux/amd64
    build:
      context: .
      target: unit-lint
    volumes:
      - ./src:/app/src
      - ./tests:/app/tests
    environment:
      SKIP_LINT: 0
      SKIP_TYPE_CHECKS: 0
      SKIP_TESTS: 0
      TEST_ARGS: -v
      SKIP_COV: 0
      AWS_ENDPOINT_URL: http://moto-server:5000
      AWS_ACCESS_KEY_ID: test
      AWS_SECRET_ACCESS_KEY: test
      AWS_DEFAULT_REGION: us-east-1
    depends_on:
      moto-server:
        condition: service_healthy
    entrypoint: []
    command: ./lint-and-test.sh
  lockfile:
    platform: linux/amd64
    build:
      context: .
      target: base
    entrypoint: []
    command: ["uv", "lock", "--upgrade"]
    volumes:
      - ./pyproject.toml:/app/pyproject.toml
      - ./uv.lock:/app/uv.lock
  dev-validate-atmos:
    platform: linux/amd64
    build:
      context: .
      target: dev
    volumes:
      - ./src:/app/src
      - ./dev:/app/dev
      - ./tests:/app/tests
    environment:
      - AWS_ACCESS_KEY_ID
      - AWS_SECRET_ACCESS_KEY
      - AWS_SESSION_TOKEN
      - AWS_REGION
      - AWS_DEFAULT_REGION
    entrypoint: ["python", "-m", "dev.validate_atmos"]
  dev-handle-task:
    platform: linux/amd64
    build:
      context: .
      target: dev
    volumes:
      - ./src:/app/src
      - ./dev:/app/dev
      - ./tests:/app/tests
    environment:
      - AWS_ACCESS_KEY_ID
      - AWS_SECRET_ACCESS_KEY
      - AWS_SESSION_TOKEN
      - AWS_REGION
      - AWS_DEFAULT_REGION
      # SQS goes to moto-server; S3 stays on real AWS so we test against
      # the real assets the SFN message references.
      - AWS_ENDPOINT_URL_SQS=http://moto-server:5000
    depends_on:
      moto-server:
        condition: service_healthy
    entrypoint: ["python", "-m", "dev.handle_task"]
