version: "3.8"
services:
  backend:
    build: ./backend
    volumes:
      - ./backend:/usr/src/app
      - /usr/src/app/node_modules
    ports:
      - "8888:8888"
    environment:
      - NODE_ENV=development
      - DATABASE=mongodb://mongo:27017/local-idurar-erp-crp
      - PORT=8888
      - NODE_OPTIONS=--openssl-legacy-provider
      - JWT_SECRET=secret_key_1234

    command: sh -c "npm run setup && npm run dev"

    networks:
      - server-mongo

    depends_on:
      - mongo

  frontend:
    build: ./frontend
    volumes:
      - ./frontend:/usr/src/app
      - /usr/src/app/node_modules
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=development
      - REACT_APP_API_URL=http://backend:8888/api
      - NODE_OPTIONS=--openssl-legacy-provider

    depends_on:
      - backend

  mongo:
    image: mongo
    volumes:
      - mongodb_data:/data/db
    networks:
      - server-mongo

volumes:
  mongodb_data:

networks:
  server-mongo:
