version: "3.8"

services:
  backend:
    build: ./backend
    ports:
      - "3000:3000"
    volumes:
      - ./backend:/app
    depends_on:
      - mysql
    environment:
      DB_HOST: mysql
      DB_USER: corps_directory_dev
      DB_PASSWORD: corps_db_password
      DB_NAME: corps_directory_db

  frontend:
    build: ./frontend
    ports:
      - "8080:3000"
    environment:
      - REACT_APP_API_URL=http://localhost:3000/api
      - NODE_ENV=development
    depends_on:
      - backend
    command: npm start # Ensure it runs in development mode

  mysql:
    image: mysql:8.0
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: root_password
      MYSQL_DATABASE: corps_directory_db
      MYSQL_USER: corps_directory_dev
      MYSQL_PASSWORD: corps_db_password
    volumes:
      - db_data:/var/lib/mysql

volumes:
  db_data:
