version: '3.8'

services:
  mysql:
    image: mysql:8.0
    container_name: patient-management-mysql-dev
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_DATABASE: patient_management_dev
      MYSQL_USER: app_user
      MYSQL_PASSWORD: app_password
    ports:
      - "3307:3306"
    volumes:
      - mysql_dev_data:/var/lib/mysql
    networks:
      - patient-management-dev-network
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      timeout: 20s
      retries: 10

  app:
    build:
      context: .
      dockerfile: Dockerfile.dev
    container_name: patient-management-app-dev
    environment:
      NODE_ENV: development
      PORT: 3000
      DB_HOST: mysql
      DB_PORT: 3306
      DB_NAME: patient_management_dev
      DB_USER: app_user
      DB_PASSWORD: app_password
      JWT_SECRET: dev-jwt-secret-key
      JWT_REFRESH_SECRET: dev-refresh-secret-key
      JWT_ACCESS_EXPIRES_IN: 15m
      JWT_REFRESH_EXPIRES_IN: 7d
      BCRYPT_SALT_ROUNDS: 12
      RATE_LIMIT_WINDOW_MS: 900000
      RATE_LIMIT_MAX_REQUESTS: 1000
      LOG_LEVEL: debug
    ports:
      - "3000:3000"
    depends_on:
      mysql:
        condition: service_healthy
    networks:
      - patient-management-dev-network
    volumes:
      - .:/app
      - /app/node_modules
      - ./logs:/app/logs
    command: npm run dev

volumes:
  mysql_dev_data:

networks:
  patient-management-dev-network:
    driver: bridge

