# ISISeg huijutec.cn direct deployment.
# This file is prefilled for https://isiseg.huijutec.cn and frpc remotePort 10004.
# Run:
#   docker compose -f docker_compose_huijutec.yaml up -d --build

name: isiseg_huijutec

services:
  isiseg_app:
    image: isiseg/app:huijutec-20260518
    build:
      context: .
      dockerfile: Dockerfile
    restart: unless-stopped
    environment:
      TZ: Asia/Shanghai
      PORT: 8001
      PUBLIC_URL: https://isiseg.huijutec.cn
    ports:
      - "10004:8001"
    volumes:
      - ./data/uploads:/app/storage/uploads
      - ./data/jobs:/app/storage/jobs
    healthcheck:
      test: ["CMD-SHELL", "python -c \"import urllib.request; urllib.request.urlopen('http://127.0.0.1:8001/api/health', timeout=3).read()\""]
      interval: 10s
      timeout: 5s
      retries: 12
      start_period: 20s

  isiseg_frpc:
    image: snowdreamtech/frpc:latest
    restart: unless-stopped
    entrypoint: ["/bin/sh"]
    command:
      - -c
      - |
        cat > /tmp/frpc.toml <<'EOF'
        serverAddr = "82.157.255.195"
        serverPort = 7000

        auth.method = "token"
        auth.token = "en.xjtu.edu.cn"

        transport.poolCount = 5
        transport.heartbeatTimeout = -1

        [[proxies]]
        name = "ISISeg"
        type = "tcp"
        localIP = "isiseg_app"
        localPort = 8001
        remotePort = 10004
        EOF
        exec frpc -c /tmp/frpc.toml
    depends_on:
      isiseg_app:
        condition: service_healthy
