services:
  db:
    image: mysql:8.0
    container_name: petshop-db
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: Petstoredb
      MYSQL_USER: petshop
      MYSQL_PASSWORD: petshop
    ports:
      - "3306:3306"
    volumes:
      - db_data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-uroot", "-proot"]
      interval: 10s
      timeout: 5s
      retries: 30
      start_period: 40s

volumes:
  db_data:
