version: "3.8"

services:
  soul-book:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: soul_book_app
    restart: always
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=production
      - NEXT_TELEMETRY_DISABLED=1
      # 支付宝配置
      - ALIPAY_PARTNER_ID=${ALIPAY_PARTNER_ID:-2088511801157159}
      - ALIPAY_KEY=${ALIPAY_KEY:-lz6ey1h3kl9zqkgtjz3avb5gk37wzbrp}
      - ALIPAY_APP_ID=${ALIPAY_APP_ID:-wx432c93e275548671}
      - ALIPAY_RETURN_URL=${ALIPAY_RETURN_URL:-http://192.168.2.201:3000/payment/success}
      - ALIPAY_NOTIFY_URL=${ALIPAY_NOTIFY_URL:-http://192.168.2.201:3000/api/payment/alipay/notify}
      # 微信支付配置
      - WECHAT_APP_ID=${WECHAT_APP_ID:-wx432c93e275548671}
      - WECHAT_APP_SECRET=${WECHAT_APP_SECRET:-25b7e7fdb7998e5107e242ebb6ddabd0}
      - WECHAT_MCH_ID=${WECHAT_MCH_ID:-1318592501}
      - WECHAT_API_KEY=${WECHAT_API_KEY:-wx3e31b068be59ddc131b068be59ddc2}
      - WECHAT_NOTIFY_URL=${WECHAT_NOTIFY_URL:-http://192.168.2.201:3000/api/payment/wechat/notify}
      # 基础配置
      - NEXT_PUBLIC_BASE_URL=${NEXT_PUBLIC_BASE_URL:-http://192.168.2.201:3000}
    volumes:
      - ./book:/app/book:ro
      - ./public:/app/public:ro
    networks:
      - nas-network
    healthcheck:
      test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

networks:
  nas-network:
    external: true
