version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: digital-aura-app
    restart: unless-stopped
    working_dir: /var/www/html
    volumes:
      - .:/var/www/html
      - ./storage:/var/www/html/storage
    depends_on:
      - db
      - redis
    environment:
      - APP_ENV=production
      - APP_DEBUG=false
    networks:
      - digital-aura-network

  nginx:
    image: nginx:alpine
    container_name: digital-aura-nginx
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - .:/var/www/html
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
      - ./storage:/var/www/html/storage
    depends_on:
      - app
    networks:
      - digital-aura-network

  db:
    image: mysql:8.0
    container_name: digital-aura-db
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: digital_aura_business
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
      MYSQL_USER: ${DB_USERNAME:-laravel}
      MYSQL_PASSWORD: ${DB_PASSWORD}
    volumes:
      - mysql_data:/var/lib/mysql
    ports:
      - "3306:3306"
    networks:
      - digital-aura-network

  redis:
    image: redis:alpine
    container_name: digital-aura-redis
    restart: unless-stopped
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    networks:
      - digital-aura-network

  node:
    image: node:20-alpine
    container_name: digital-aura-node
    working_dir: /var/www/html
    volumes:
      - .:/var/www/html
    command: npm run build
    networks:
      - digital-aura-network

volumes:
  mysql_data:
    driver: local
  redis_data:
    driver: local

networks:
  digital-aura-network:
    driver: bridge
