version: '3.8'

services:
  # Aplicação Laravel
  app:
    image: webdevops/php-nginx:8.3-alpine
    container_name: waygest_gestao_app
    restart: unless-stopped
    working_dir: /var/www/html
    volumes:
      - .:/var/www/html
      - ./storage:/var/www/html/storage
    ports:
      - "8080:8000"
    environment:
      - APP_ENV=local
      - APP_DEBUG=true
      - APP_KEY=base64:TRbXQQmofREDSI8LfXlbli4qRKAQ1V2pI7sje5fAYqo=
      - APP_URL=http://gestao.waygest.local:8888
      - DB_CONNECTION=mysql
      - DB_HOST=mysql
      - DB_PORT=3306
      - DB_DATABASE=waygest_gestao
      - DB_USERNAME=root
      - DB_PASSWORD=root
      - CACHE_DRIVER=file
      - SESSION_DRIVER=file
    command: sh -c "mkdir -p /var/www/html/storage/app/public /var/www/html/storage/framework/cache/data /var/www/html/storage/framework/sessions /var/www/html/storage/framework/views /var/www/html/storage/logs /var/www/html/bootstrap/cache && chmod -R 755 /var/www/html/storage /var/www/html/bootstrap/cache && php artisan serve --host=0.0.0.0 --port=8000"
    depends_on:
      - mysql
      - redis
    networks:
      - waygest_gestao

  # Banco de dados MySQL
  mysql:
    image: mysql:8.0
    container_name: waygest_gestao_mysql
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: waygest_gestao
      MYSQL_ROOT_PASSWORD: root
      MYSQL_PASSWORD: root
      MYSQL_USER: waygest
    ports:
      - "3307:3306"
    volumes:
      - mysql_data:/var/lib/mysql
    networks:
      - waygest_gestao

  # Redis para cache
  redis:
    image: redis:7-alpine
    container_name: waygest_gestao_redis
    restart: unless-stopped
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    networks:
      - waygest_gestao

  # Nginx
  nginx:
    image: nginx:alpine
    container_name: waygest_gestao_nginx
    restart: unless-stopped
    ports:
      - "8888:80"
    volumes:
      - .:/var/www
      - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - app
    networks:
      - waygest_gestao

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

networks:
  waygest_gestao:
    driver: bridge
