services:
  test-db:
    image: mysql:8.0
    container_name: alrahma_test_db
    command:
      - --default-authentication-plugin=mysql_native_password
    environment:
      MYSQL_DATABASE: ${TEST_DB_DATABASE:-school_api_test}
      MYSQL_USER: ${TEST_DB_USERNAME:-school}
      MYSQL_PASSWORD: ${TEST_DB_PASSWORD:-school}
      MYSQL_ROOT_PASSWORD: ${TEST_DB_ROOT_PASSWORD:-root}
    ports:
      - "${TEST_DB_PORT:-33106}:3306"
    # Store data in RAM so the test database is fast and ephemeral.
    tmpfs:
      - /var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-uroot", "-p${TEST_DB_ROOT_PASSWORD:-root}"]
      interval: 3s
      timeout: 3s
      retries: 30
