version: '3.8'

services:
  backend:
    image: reading-platform-backend:latest
    build:
      context: ./reading-platform-java
    container_name: kg-backend
    restart: unless-stopped
    ports:
      - "8080:8080"
      - "5005:5005"  # JDWP 调试端口
    environment:
      - SPRING_PROFILES_ACTIVE=prod
      - SPRING_DATASOURCE_URL=jdbc:mysql://8.148.151.56:3306/reading_platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
      - SPRING_DATASOURCE_USERNAME=root
      - SPRING_DATASOURCE_PASSWORD=reading_platform_pwd
      - SPRING_FLYWAY_ENABLED=false
      - JWT_SECRET=${JWT_SECRET:-reading-platform-jwt-secret-key-must-be-at-least-256-bits-long}
      - JAVA_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005  # 启用远程调试
    volumes:
      - uploads_data:/app/uploads

  frontend:
    image: reading-platform-frontend:latest
    build:
      context: ./reading-platform-frontend
    container_name: kg-frontend
    restart: unless-stopped
    ports:
      - "3000:80"
    depends_on:
      - backend

volumes:
  uploads_data:
