kind: pipeline
name: dev
trigger:
  branch:
    - dev
clone:
  disable: true

volumes:
  - name: docker-sock
    host:
      path: /var/run/docker.sock

##-------------------------------流水线⬇-------------------------------##
steps: # 定义流水线执行步骤，这些步骤将顺序执行
  - name: fetch
    image: registry.cn-qingdao.aliyuncs.com/wod/devops-git:1.0
    network_mode: host

  - name: build # 项目打包
    image: registry.cn-qingdao.aliyuncs.com/wod/devops-node:12.18.0-stretch
    # 将宿主机中文件夹挂载到容器中，宿主机文件夹中的文件会被容器访问并修改，起到使用缓存的作用，避免每次运行都要重现下载依赖，提高运行速度
    commands:
      - unzip dist.zip

  - name: docker-amd64
    image: registry.cn-qingdao.aliyuncs.com/wod/devops-docker:1.0
    # 将宿主机的 docker和配置挂载到运行的 docker 容器中，那么在容器中运行 docker 命令时，等同于在宿主机中运行该docker命令
    volumes:
      - name: docker-sock
        path: /var/run/docker.sock # 将下载依赖的目录挂载出来，防止重复下载
    settings: # 当前设置
      base: registry.cn-qingdao.aliyuncs.com/wod/ui-base:v6.1-amd64 # 基础镜像
      dockerfile: .beagle/dockerfile
      repo: zjk/zjk-ui # 生成镜像的 分组/名称
      version: "v1.0.0" # 版本号
      channel: amd64 # 后缀
      args: "TARGETOS=linux,TARGETARCH=amd64" # 不同架构的构建参数
      registry: hub.wodcloud.com # 私有仓库地址
      registry_user: # 用户
        from_secret: REGISTRY_USER
      registry_password: # 密码
        from_secret: REGISTRY_PASSWORD

  - name: docker-arm64
    image: registry.cn-qingdao.aliyuncs.com/wod/devops-docker:1.0
    volumes:
      - name: docker-sock
        path: /var/run/docker.sock
    settings:
      base: registry.cn-qingdao.aliyuncs.com/wod/ui-base:v6.1-arm64
      dockerfile: .beagle/dockerfile
      repo: zjk/zjk-ui
      version: "v1.0.0"
      channel: arm64
      args: "TARGETOS=linux,TARGETARCH=arm64"
      registry: hub.wodcloud.com
      registry_user:
        from_secret: REGISTRY_USER
      registry_password:
        from_secret: REGISTRY_PASSWORD

---
clone:
  disable: true

trigger:
  branch:
    - master

kind: pipeline
name: master
steps:
  - name: harbor-amd64
    image: registry.cn-qingdao.aliyuncs.com/wod/devops-docker-tag:1.0
    volumes:
      - name: docker-sock
        path: /var/run/docker.sock
    pull: always
    environment:
      http_proxy: http://10.11.92.33:1282
      https_proxy: http://10.11.92.33:1282
      REGISTRY_USER:
        from_secret: REGISTRY_USER
      REGISTRY_PASSWORD:
        from_secret: REGISTRY_PASSWORD
    settings:
      source: hub.wodcloud.com/zjk/zjk-ui:v1.0.0-amd64
      target: hub.wodcloud.com/zjk/zjk-ui:v1.0.0-amd64
      registry: hub.wodcloud.com

  - name: harbor-arm64
    image: registry.cn-qingdao.aliyuncs.com/wod/devops-docker-tag:1.0
    volumes:
      - name: docker-sock
        path: /var/run/docker.sock
    pull: always
    environment:
      http_proxy: http://10.11.92.33:1282
      https_proxy: http://10.11.92.33:1282
      REGISTRY_USER:
        from_secret: REGISTRY_USER
      REGISTRY_PASSWORD:
        from_secret: REGISTRY_PASSWORD
    settings:
      source: hub.wodcloud.com/zjk/zjk-ui:v1.0.0-arm64
      target: hub.wodcloud.com/zjk/zjk-ui:v1.0.0-arm64
      registry: hub.wodcloud.com

##--------------对于需要保密的信息隐藏，减少账户信息的泄密⬇-----------------##
---
kind: secret
name: REGISTRY_USER
get:
  name: REGISTRY_USER
  path: devops-secrets
---
kind: secret
name: REGISTRY_PASSWORD
get:
  name: REGISTRY_PASSWORD
  path: devops-secrets
---
kind: secret
name: KUBERNETES_SERVER
get:
  name: KUBERNETES_SERVER
  path: devops-secrets
---
kind: secret
name: KUBERNETES_TOKEN
get:
  name: KUBERNETES_TOKEN
  path: devops-secrets
---
kind: secret
name: ACCESS_KEY_MINIO
get:
  name: ACCESS_KEY_MINIO
  path: devops-secrets

---
kind: secret
name: SECRET_KEY_MINIO
get:
  name: SECRET_KEY_MINIO
  path: devops-secrets
