services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
      target: local
    container_name: sibedas_app_local
    restart: unless-stopped
    environment:
      APP_ENV: local
      APP_DEBUG: true
      APP_URL: http://localhost:8000
      VITE_APP_URL: http://localhost:8000
      DB_CONNECTION: mariadb
      DB_HOST: db
      DB_PORT: 3306
      DB_DATABASE: siebdas_20250815
      DB_USERNAME: root
      DB_PASSWORD: root
    volumes:
      - .:/var/www
      # Exclude node_modules to prevent conflicts
      - /var/www/node_modules
    depends_on:
      - db
    networks:
      - sibedas_network_local
    # Add user mapping for permission compatibility
    user: "1000:1000"

  nginx:
    image: nginx:alpine
    container_name: sibedas_nginx_local
    restart: unless-stopped
    ports:
      - "8000:80"
    volumes:
      - .:/var/www
      - ./docker/nginx/conf.d/app.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - app
    networks:
      - sibedas_network_local

  db:
    image: mariadb:10.6
    container_name: sibedas_db_local
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: siebdas_20250815
    ports:
      - "3306:3306"
    volumes:
      - sibedas_dbdata_local:/var/lib/mysql
      - ./sibedas.sql:/docker-entrypoint-initdb.d/sibedas.sql
    networks:
      - sibedas_network_local

  vite:
    build:
      context: .
      dockerfile: Dockerfile
      target: development
    container_name: sibedas_vite_local
    restart: unless-stopped
    environment:
      VITE_APP_URL: http://localhost:8000
    volumes:
      - .:/var/www
      - /var/www/node_modules
    ports:
      - "5173:5173"
    networks:
      - sibedas_network_local

volumes:
  sibedas_dbdata_local:

networks:
  sibedas_network_local:
    driver: bridge
