version: "3.9"

services:
  app:
    build: .
    container_name: daily-lvt-mkt-app
    restart: unless-stopped
    environment:
      APP_ENV: local
      APP_DEBUG: "true"
      APP_URL: http://localhost
      DB_CONNECTION: mysql
      DB_HOST: 127.0.0.1
      DB_PORT: 3306
      DB_DATABASE: daily_lvt_mkt
      DB_USERNAME: root
      DB_PASSWORD: root
    volumes:
      - ./:/var/www/html
    depends_on:
      - db

  nginx:
    image: nginx:1.25-alpine
    container_name: daily-lvt-mkt-nginx
    restart: unless-stopped
    ports:
      - "80:80"
    volumes:
      - ./:/var/www/html
      - ./deploy/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      - app

  db:
    image: mysql:8.0
    container_name: daily-lvt-mkt-db
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: daily_lvt_mkt
      MYSQL_USER: daily
      MYSQL_PASSWORD: secret
      MYSQL_ROOT_PASSWORD: root
    ports:
      - "3306:3306"
    command: ["mysqld", "--default-authentication-plugin=mysql_native_password", "--sql-mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"]
    volumes:
      - db_data:/var/lib/mysql

  queue:
    build: .
    container_name: daily-lvt-mkt-queue
    restart: unless-stopped
    command: php artisan queue:work --sleep=1 --tries=3 --memory=256 --verbose
    depends_on:
      - app
      - db
    volumes:
      - ./:/var/www/html

  scheduler:
    build: .
    container_name: daily-lvt-mkt-scheduler
    restart: unless-stopped
    command: sh -c "while [ true ]; do php artisan schedule:run --verbose --no-interaction; sleep 60; done"
    depends_on:
      - app
      - db
    volumes:
      - ./:/var/www/html

volumes:
  db_data:


