version: v1.0
name: Docker
agent:
  machine:
    type: r1-standard-4
    os_image: ubuntu2404
blocks:
  - name: Build Standard Docker image
    task:
      jobs:
        - name: docker build
          commands:
            - checkout
            - docker buildx create --platform=linux/amd64,linux/arm64 --use
            - docker buildx build --platform=linux/amd64,linux/arm64 .
    dependencies: []
  - name: Build npm package
    dependencies: []
    task:
      jobs:
        - name: npm test
          commands:
            - checkout
            - install-package libzmq3-dev libprotobuf-dev graphicsmagick yasm gulp python3 pkg-config curl zip unzip wget build-essential cmake ninja-build git --update
            - sem-version node 22
            - export PATH=$PWD/node_modules/.bin:$PATH 
            - sed -i'' -e '/phantomjs/d' package.json
            - export VCPKG_FORCE_SYSTEM_BINARIES="arm"
            - npm install --save-dev pnpm
            - npm install --python="/usr/bin/python3" --omit=optional --loglevel http
            - npm test
  - name: Build Debian Docker image
    dependencies: []
    task:
      jobs:
        - name: docker build
          commands:
            - checkout
            - docker buildx create --platform=linux/amd64 --use
            - docker buildx build --platform=linux/amd64 . -f Dockerfile-debian-x86_64
promotions:
  - name: Deploy to DockerHub
    pipeline_file: deploy_dockerhub.yml
    auto_promote:
      when: (branch = 'master' OR tag =~ '.*') AND result = 'passed'
  - name: Deploy to npmjs
    pipeline_file: deploy_npmjs.yml
    auto_promote:
      when: tag =~ '.*' AND result = 'passed'
