services:
  app:
    build:
      context: .
      dockerfile: docker/php/Dockerfile
    image: kickimpact/app:local
    restart: unless-stopped
    working_dir: /var/www/html
    volumes:
      - .:/var/www/html
    environment:
      APP_ENV: local
      DB_HOST: mysql
      REDIS_HOST: redis
    depends_on:
      - mysql
      - redis

  nginx:
    image: nginx:1.27-alpine
    restart: unless-stopped
    ports:
      - "8000:80"
    volumes:
      - .:/var/www/html:ro
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      - app

  mysql:
    image: mysql:8.4
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: kickimpact
      MYSQL_USER: kickimpact
      MYSQL_PASSWORD: secret
      MYSQL_ROOT_PASSWORD: root
    ports:
      - "3306:3306"
    volumes:
      - mysql-data:/var/lib/mysql

  redis:
    image: redis:7.4-alpine
    restart: unless-stopped
    ports:
      - "6379:6379"

  queue:
    image: kickimpact/app:local
    restart: unless-stopped
    working_dir: /var/www/html
    command: php artisan horizon
    volumes:
      - .:/var/www/html
    depends_on:
      - app
      - redis
      - mysql

  scheduler:
    image: kickimpact/app:local
    restart: unless-stopped
    working_dir: /var/www/html
    command: sh -c "while true; do php artisan schedule:run --verbose --no-interaction; sleep 60; done"
    volumes:
      - .:/var/www/html
    depends_on:
      - app
      - redis
      - mysql

volumes:
  mysql-data:
