services:
  mysql:
    image: mysql:8.4
    container_name: mobilemodels-mysql
    command:
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_0900_ai_ci
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-mobilemodels_root}
      MYSQL_DATABASE: ${MYSQL_DATABASE:-mobilemodels}
    ports:
      - "3306:3306"
    volumes:
      - mobilemodels_mysql_data:/var/lib/mysql
    healthcheck:
      test: ["CMD-SHELL", "mysqladmin ping -h127.0.0.1 -uroot -p$$MYSQL_ROOT_PASSWORD --silent"]
      interval: 5s
      timeout: 5s
      retries: 30
      start_period: 20s
    restart: unless-stopped
    init: true

  mobilemodels:
    environment:
      MYSQL_HOST: mysql
      MYSQL_PORT: 3306
      MYSQL_ROOT_USER: root
      MYSQL_AUTO_LOAD: 1
    depends_on:
      mysql:
        condition: service_healthy

volumes:
  mobilemodels_mysql_data:
