version: '3.8'

services:
  # Aplicação Laravel
  app:
    image: webdevops/php-nginx:8.3-alpine
    container_name: laravel_app
    restart: unless-stopped
    working_dir: /var/www/html
    volumes:
      - .:/var/www/html
      - ./storage:/var/www/html/storage
    ports:
      - "8000:8000"
    environment:
      - APP_ENV=local
      - APP_DEBUG=true
      - APP_KEY=base64:TRbXQQmofREDSI8LfXlbli4qRKAQ1V2pI7sje5fAYqo=
      - APP_URL=http://localhost:8000
      - 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
    networks:
      - app_network

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

volumes:
  mysql_data:
    driver: local

networks:
  app_network:
    driver: bridge
