# ============================================================
# TagServer 模块统一 Docker Compose 配置
# 包含 tagserver（PHP/Python 后端 + Nginx）与 eptagsrv（Tomcat/MQTT）服务
# ============================================================

version: '3.8'

# ===================== 网络定义 =====================
networks:
  docker-shared-network:
    external: true
    name: docker-shared-network

# ===================== 服务定义 =====================
services:
  # --------------------------------------------------
  # 服务〇：frpc
  # 功能：FRP 反向代理客户端，将本地服务暴露到公网服务器 47.119.42.70
  # --------------------------------------------------
  frpc:
    image: snowdreamtech/frpc:0.61.2
    container_name: frpc
    restart: unless-stopped
    network_mode: host
    volumes:
      - ./frpc/frpc.toml:/etc/frp/frpc.toml:ro

  # --------------------------------------------------
  # 服务一：tagserver
  # 功能：Nginx + PHP + Python 后端 + MySQL
  # --------------------------------------------------
  tag:
    image: fy93.cn:5000/tagserver:latest
    container_name: tagserver
    restart: unless-stopped
    ports:
      - "180:80"      # → frpc → 远程 80 (Web)
      - "1443:443"    # → frpc → 远程 443 (SSL)
    volumes:
      # 资源与代码目录
      - ./resource:/var/www/html/resource
      - ./db/mysql:/var/lib/mysql          # MySQL 数据持久化
      - ./disk/letsencrypt:/etc/letsencrypt  # certbot SSL 证书持久化
      - ./disk/log/python_app:/opt/python_app/logs
      - ./disk/log/webservice:/opt/webservice/logs
    environment:
      relay_address: "http://eptagsrv"
      DOMAIN: "fwq-iot.club"
      EMAIL: "fy93@163.com"
    depends_on: []
    networks:
      - docker-shared-network

  # --------------------------------------------------
  # 服务二：eptagsrv
  # 功能：Tomcat + MQTT 服务
  # --------------------------------------------------
  eptagsrv:
    image: fy93.cn:5000/eptagsrv:latest
    container_name: eptagsrv
    restart: unless-stopped
    ports:
      - "8080:8080"   # Tomcat 端口
      - "11883:1883"  # → frpc → 远程 1883 (MQTT)
    volumes:
      - ./opt_EPTagsSrv:/opt/EPTagsSrv
    environment:
      SERVER_DOMAIN: "https://fwq-iot.club"
    depends_on: []
    networks:
      - docker-shared-network

