version: '3.8'

services:
  product-svc:
    container_name: productservice
    build: ./productSvc
    ports:              # use 'ports' instead of 'expose' for host access
      - "8020:8020"
    environment:
      APP_INTERNAL_PORT: 8020
      DB_ADDRESS: mysql
      DB_PORT: 3306
      DB_NAME: productmngm
      DB_USERNAME: root
      DB_PASSWORD: S3cret
    restart: unless-stopped  
    depends_on:
      - mysql
    networks:
      - my-network  

  mysql:
    container_name: mysql
    image: mysql:latest
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: S3cret
      MYSQL_DATABASE: productmngm
    ports:
      - "3306:3306"
    volumes:
      - mysql-data:/var/lib/mysql
    networks:
      - my-network  

  nginx:
    container_name: nginx
    image: nginx:latest
    ports:
      - "80:80"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
    depends_on:
      - product-svc
    networks:
      - my-network  

  product-ui:
    container_name: product-ui
    build: ./productApp     # path to your React app Dockerfile folder
    ports:
      - "8030:80"         # map container port 80 (nginx) to host 3000 
    networks:
      - my-network  

volumes:
  mysql-data:

networks:
  my-network:
    driver: bridge  
