services:
  # PHP Service
  php:
    build:
      context: .
      dockerfile: docker/php/Dockerfile
    container_name: ecom01-php
    volumes:
      - ./admin:/var/www/admin
    networks:
      - ecom01-network

  # Nginx Service
  nginx:
    image: nginx:stable-alpine
    container_name: ecom01-nginx
    ports:
      - "80:80"
    volumes:
      - ./admin:/var/www/admin
      - ./frontend:/var/www/frontend
      - ./docker/nginx/conf.d:/etc/nginx/conf.d
    depends_on:
      - php
      - frontend
    networks:
      - ecom01-network

  # MySQL Service
  mysql:
    image: mysql:8.0
    container_name: ecom01-mysql
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: ecom01
      MYSQL_USER: ecom01
      MYSQL_PASSWORD: ecom01
      MYSQL_ROOT_PASSWORD: root
    ports:
      - "3306:3306"
    volumes:
      - mysql-data:/var/lib/mysql
    networks:
      - ecom01-network

  # Node/Frontend Service
  frontend:
    build:
      context: .
      dockerfile: docker/node/Dockerfile
      target: dev
    container_name: ecom01-frontend
    volumes:
      - ./frontend:/app
    ports:
      - "3000:3000"
    environment:
      SERVER_API_URL: http://nginx
      SERVER_API_HOST: admin.localhost
    command: npm run dev
    networks:
      - ecom01-network

  # Redis Service
  redis:
    image: redis:alpine
    container_name: ecom01-redis
    networks:
      - ecom01-network

networks:
  ecom01-network:
    driver: bridge

volumes:
  mysql-data:
    driver: local
