version: "3.8"

services:
  app:
    build: .
    container_name: colih-app
    ports:
      - "8080:80"
    volumes:
      - .:/var/www/html
      - /var/www/html/node_modules
      - /var/www/html/vendor
    environment:
      - APP_ENV=development
      - APP_DEBUG=true
      - DB_HOST=db
      - DB_PORT=3306
      - DB_DATABASE=colih
      - DB_USERNAME=root
      - DB_PASSWORD=root
      - REDIS_HOST=redis
      - REDIS_PORT=6379
      - QUEUE_CONNECTION=redis
      - CACHE_DRIVER=redis
      - SESSION_DRIVER=redis
    depends_on:
      - db
      - redis
    networks:
      - colih-network

  db:
    image: mysql:8.0
    container_name: colih-db
    restart: always
    environment:
      MYSQL_DATABASE: colih
      MYSQL_ROOT_PASSWORD: root
      MYSQL_CHARACTER_SET_SERVER: utf8mb4
      MYSQL_COLLATION_SERVER: utf8mb4_unicode_ci
    volumes:
      - db_data:/var/lib/mysql
    ports:
      - "3307:3306"
    networks:
      - colih-network
    command: --default-authentication-plugin=mysql_native_password

  redis:
    image: redis:7-alpine
    container_name: colih-redis
    restart: always
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    networks:
      - colih-network

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: colih-pma
    restart: always
    environment:
      PMA_HOST: db
      PMA_PORT: 3306
      PMA_USER: root
      PMA_PASSWORD: root
    ports:
      - "8081:80"
    depends_on:
      - db
    networks:
      - colih-network

  queue:
    build: .
    container_name: colih-queue
    command: php artisan queue:work --verbose --tries=3 --timeout=90
    volumes:
      - .:/var/www/html
      - /var/www/html/node_modules
      - /var/www/html/vendor
    environment:
      - APP_ENV=development
      - APP_DEBUG=true
      - DB_HOST=db
      - DB_PORT=3306
      - DB_DATABASE=colih
      - DB_USERNAME=root
      - DB_PASSWORD=root
      - REDIS_HOST=redis
      - REDIS_PORT=6379
      - QUEUE_CONNECTION=redis
    depends_on:
      - db
      - redis
    networks:
      - colih-network

volumes:
  db_data:
  redis_data:

networks:
  colih-network:
    driver: bridge
