services:
  # Servicio PHP 8.1 con Composer
  app:
    build:
      context: .
      dockerfile: docker/php/Dockerfile
    container_name: egurrola_app
    restart: unless-stopped
    working_dir: /var/www/html
    volumes:
      - ./:/var/www/html
      - ./docker/php/php.ini:/usr/local/etc/php/conf.d/custom.ini
    networks:
      - egurrola_network
    depends_on:
      - mysql
    environment:
      - DB_HOST=mysql
      - DB_PORT=3306
      - DB_DATABASE=spa
      - DB_USERNAME=root
      - DB_PASSWORD=root_password

  # Servicio Nginx
  nginx:
    image: nginx:alpine
    container_name: egurrola_nginx
    restart: unless-stopped
    ports:
      - "8000:80"
    volumes:
      - ./:/var/www/html
      - ./docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
    networks:
      - egurrola_network
    depends_on:
      - app

  # Servicio Node 18.17.1
  node:
    build:
      context: .
      dockerfile: docker/node/Dockerfile
    container_name: egurrola_node
    restart: unless-stopped
    working_dir: /var/www/html
    volumes:
      - ./:/var/www/html
      - node_modules:/var/www/html/node_modules
    networks:
      - egurrola_network
    command: tail -f /dev/null

  # Servicio MySQL
  mysql:
    image: mysql:8.0
    container_name: egurrola_mysql
    restart: unless-stopped
    ports:
      - "3307:3306"
    environment:
      MYSQL_DATABASE: egurrola
      MYSQL_USER: egurrola_user
      MYSQL_PASSWORD: egurrola_password
      MYSQL_ROOT_PASSWORD: root_password
    volumes:
      - mysql_data:/var/lib/mysql
      - ./docker/mysql/my.cnf:/etc/mysql/conf.d/custom.cnf
      - ./docker/mysql/init.sql:/docker-entrypoint-initdb.d/init.sql
    networks:
      - egurrola_network

  # Servicio phpMyAdmin
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: egurrola_phpmyadmin
    restart: unless-stopped
    ports:
      - "8081:80"
    environment:
      PMA_HOST: mysql
      PMA_PORT: 3306
      PMA_USER: root
      PMA_PASSWORD: root_password
      UPLOAD_LIMIT: 300M
    networks:
      - egurrola_network
    depends_on:
      - mysql

volumes:
  mysql_data:
    driver: local
  node_modules:
    driver: local

networks:
  egurrola_network:
    driver: bridge


