---
services:
  aws-os-proxy:
    platform: linux/amd64
    image: abutaha/aws-es-proxy
    ports:
      - "5002:80"
    command: >
      -endpoint https://${OPENSEARCH_HOST}
      -listen 0.0.0.0:80
      -debug
    environment:
      - AWS_REGION
      - AWS_ACCESS_KEY_ID
      - AWS_SECRET_ACCESS_KEY
      - AWS_SESSION_TOKEN

  dev:
    platform: linux/amd64
    build:
      context: .
      target: dev
    volumes:
      - ./vectororder:/var/app/vectororder
    depends_on:
      - aws-os-proxy
    ports:
      - "5000:5000"
    env_file:
      - path: ./.env
        required: false
    environment:
      - AWS_ACCESS_KEY_ID
      - AWS_SECRET_ACCESS_KEY
      - AWS_SESSION_TOKEN
      - AWS_REGION
      - DD_TRACE_ENABLED=false
      - OPENSEARCH_HOST=aws-os-proxy
      - OPENSEARCH_PORT=80

  format:
    platform: linux/amd64
    build:
      context: .
      target: format
    volumes:
      - ./:/var/app

  unit-lint:
    extends:
      file: docker-compose.unit-lint.yml
      service: unit-lint

  update-snapshots:
    extends:
      file: docker-compose.unit-lint.yml
      service: unit-lint
    environment:
      - SKIP_LINT=1
      - SKIP_TYPE_CHECKS=1
      - TEST_ARGS=--snapshot-update
    volumes:
      - ./tests:/var/app/tests

  integration:
    build:
      context: .
      target: integration
    environment:
      - TEST_ARGS=-v
      - QA_BASE_URL

  update-lockfile:
    platform: linux/amd64
    build:
      context: .
      target: update-lockfile
    volumes:
      - ./poetry.lock:/var/app/poetry.lock

  test-ar-db:
    platform: linux/amd64
    image:
      086679231553.dkr.ecr.us-east-1.amazonaws.com/docker-database-images:art-relations
    pull_policy: always
    environment:
      DB_USER: ${TEST_DB_USER}
      DB_PASSWORD: ${TEST_DB_PASS}
    command: >
      --disable-log-bin
    tmpfs:
      - /var/lib/mysql
    healthcheck:
      interval: 1s
      timeout: 5s
      retries: 180

  test-dd-db:
    platform: linux/amd64
    image:
      086679231553.dkr.ecr.us-east-1.amazonaws.com/docker-database-images:direct-delivery-cluster
    pull_policy: always
    environment:
      DB_USER: ${TEST_DD_USER}
      DB_PASSWORD: ${TEST_DD_PASS}
    command: >
      --disable-log-bin
    tmpfs:
      - /var/lib/mysql
    healthcheck:
      interval: 1s
      timeout: 5s
      retries: 120
    deploy:
      resources:
        limits:
          cpus: '1.5'
