# Docker Compose 配置 for YuanRong ARM64 远程构建
# 使用方法: docker-compose -f scripts/docker-compose.builder.yml run --rm builder

services:
  builder:
    image: swr.cn-southwest-2.myhuaweicloud.com/yuanrong-dev/compile_arm:2.1
    platform: linux/arm64
    working_dir: /workspace
    volumes:
      # 挂载项目源码
      - ../:/workspace
      # Go 模块缓存 (可选)
      - go-modules:/go/pkg/mod
      # Bazel 缓存 (可选)
      - bazel-cache:/root/.cache/bazel
    environment:
      - GO111MODULE=on
      - CGO_ENABLED=1
      - GOOS=linux
      - GOARCH=arm64
      - GOPROXY=${GOPROXY:-https://goproxy.cn,direct}
      - BUILD_VERSION=${BUILD_VERSION:-v0.0.1}
      - JOBS=${JOBS:-4}
    command: ["bash"]

  # 完整构建服务
  build-all:
    image: swr.cn-southwest-2.myhuaweicloud.com/yuanrong-dev/compile_arm:2.1
    platform: linux/arm64
    working_dir: /workspace
    volumes:
      - ../:/workspace
      - go-modules:/go/pkg/mod
      - bazel-cache:/root/.cache/bazel
    environment:
      - GO111MODULE=on
      - CGO_ENABLED=1
      - GOOS=linux
      - GOARCH=arm64
      - GOPROXY=${GOPROXY:-https://goproxy.cn,direct}
      - BUILD_VERSION=${BUILD_VERSION:-v0.0.1}
      - JOBS=${JOBS:-4}
    command: ["make", "all"]

  # 仅构建 functionsystem
  build-fs:
    extends: build-all
    command: ["make", "functionsystem"]

  # 仅构建 datasystem
  build-ds:
    extends: build-all
    command: ["make", "datasystem"]

  # 仅构建 runtime
  build-rt:
    extends: build-all
    command: ["make", "yuanrong"]

volumes:
  go-modules:
  bazel-cache: