version: '3.8'

services:
  mysql:
    image: mysql:8.0
    container_name: service-booking-mysql
    restart: unless-stopped
    ports:
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: root_password
      MYSQL_DATABASE: service_booking_db
      MYSQL_USER: service_user
      MYSQL_PASSWORD: user_password
    volumes:
      - mysql_data:/var/lib/mysql
      - ./database/init.sql:/docker-entrypoint-initdb.d/init.sql
    command: --default-authentication-plugin=mysql_native_password
    networks:
      - service-booking-network

  redis:
    image: redis:alpine
    container_name: service-booking-redis
    restart: unless-stopped
    ports:
      - "6379:6379"
    command: redis-server --requirepass redis_password
    volumes:
      - redis_data:/data
    networks:
      - service-booking-network

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: service-booking-phpmyadmin
    restart: unless-stopped
    ports:
      - "8080:80"
    environment:
      PMA_HOST: mysql
      PMA_PORT: 3306
      PMA_ARBITRARY: 1
    depends_on:
      - mysql
    networks:
      - service-booking-network

volumes:
  mysql_data:
  redis_data:

networks:
  service-booking-network:
    driver: bridge