---
services:
  function:
    platform: linux/amd64
    entrypoint: ["sleep", "infinity"]
    build:
      context: .
      target: production
      args:
        version: "local-dev"
      additional_contexts:
        common: ../../common
    ports:
      - "9000:8080"
    environment:
      - DD_ENV=dev
      - DD_SERVICE=extract-native-configuration
      - DD_TRACE_ENABLED=false
      - DD_ENHANCED_METRICS=false
      - PYTHONDONTWRITEBYTECODE=1
      - AWS_ACCESS_KEY_ID
      - AWS_SECRET_ACCESS_KEY
      - AWS_SESSION_TOKEN
      - LOGGER_LEVEL=INFO
  lint-and-test:
    platform: linux/amd64
    build:
      context: .
      target: test
      additional_contexts:
        common: ../../common
    ports:
      - "8000:8000"
    environment:
      - SKIP_LINT=0
      - TEST_ARGS=-v
      - COV_REPORT=term  # --cov-report pytest-cov option or OFF (try html!)
      - PYTHONDONTWRITEBYTECODE=1
  mysql:
    platform: linux/amd64
    image: mysql:8.0.40
    environment:
      MYSQL_USER: testuser
      MYSQL_PASSWORD: testpassword123^
      MYSQL_RANDOM_ROOT_PASSWORD: true
    volumes:
      - ./tests/sql:/docker-entrypoint-initdb.d/
    tmpfs:
      - /var/lib/mysql
    healthcheck:
      test: [
        "CMD",
        "mysql",
        "-h",
        "127.0.0.1",
        "-u",
        "testuser",
        "--password=testpassword123",
        "-e",
        "USE test_database;"
      ]
      interval: 1s
      timeout: 5s
      retries: 120
