version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: ne-sos-app
    restart: unless-stopped
    working_dir: /var/www
    volumes:
      - ./:/var/www
      - ./storage:/var/www/storage
    networks:
      - ne-sos-network
    depends_on:
      - mysql
    environment:
      - DB_HOST=mysql
      - DB_DATABASE=ne_sos
      - DB_USERNAME=ne_sos_user
      - DB_PASSWORD=ne_sos_password

  mysql:
    image: mysql:8.0
    container_name: ne-sos-mysql
    restart: unless-stopped
    ports:
      - "3306:3306"
    environment:
      MYSQL_DATABASE: ne_sos
      MYSQL_USER: ne_sos_user
      MYSQL_PASSWORD: ne_sos_password
      MYSQL_ROOT_PASSWORD: root_password
    volumes:
      - mysql_data:/var/lib/mysql
    networks:
      - ne-sos-network

  queue:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: ne-sos-queue
    restart: unless-stopped
    working_dir: /var/www
    volumes:
      - ./:/var/www
    networks:
      - ne-sos-network
    depends_on:
      - mysql
    command: php artisan queue:work --sleep=3 --tries=3 --max-time=3600
    environment:
      - DB_HOST=mysql
      - DB_DATABASE=ne_sos
      - DB_USERNAME=ne_sos_user
      - DB_PASSWORD=ne_sos_password

networks:
  ne-sos-network:
    driver: bridge

volumes:
  mysql_data:

