linuxamd64_docker_builder:
  env:
    DOCKERHUB_USER: ENCRYPTED[98e575fd2885ba39b429cdcd5c7bbfad8db12e0c4f391f0f58fea9952bf41c2d25a7567b52dc17bfff1faa810921f6de]
    DOCKERHUB_PASS: ENCRYPTED[2266391061fded5e8db8300e5a53276e4081eb8bdd73caf665e48c19ef3a8946b7bd7188f011ca588c3b9cdfd840e0fd]
  script: |
    export TAG=${CIRRUS_TAG:-latest}
    docker build -t $CIRRUS_REPO_FULL_NAME:${TAG}-amd64 . -f Dockerfile
    docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS 
    docker push $CIRRUS_REPO_FULL_NAME:${TAG}-amd64

linuxarm64_docker_builder:
  env:
    DOCKERHUB_USER: ENCRYPTED[98e575fd2885ba39b429cdcd5c7bbfad8db12e0c4f391f0f58fea9952bf41c2d25a7567b52dc17bfff1faa810921f6de]
    DOCKERHUB_PASS: ENCRYPTED[2266391061fded5e8db8300e5a53276e4081eb8bdd73caf665e48c19ef3a8946b7bd7188f011ca588c3b9cdfd840e0fd]
  script: |
    export TAG=${CIRRUS_TAG:-latest}
    docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS 
    docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
    docker build -t $CIRRUS_REPO_FULL_NAME:${TAG}-arm64 --build-arg IMAGE=arm64v8/ubuntu:22.04 . 
    docker push $CIRRUS_REPO_FULL_NAME:${TAG}-arm64

linuxarmv6_docker_builder:
  env:
    DOCKERHUB_USER: ENCRYPTED[98e575fd2885ba39b429cdcd5c7bbfad8db12e0c4f391f0f58fea9952bf41c2d25a7567b52dc17bfff1faa810921f6de]
    DOCKERHUB_PASS: ENCRYPTED[2266391061fded5e8db8300e5a53276e4081eb8bdd73caf665e48c19ef3a8946b7bd7188f011ca588c3b9cdfd840e0fd]
  script: |
    export TAG=${CIRRUS_TAG:-latest}
    docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS 
    docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
    docker build -t $CIRRUS_REPO_FULL_NAME:${TAG}-armv6 --build-arg IMAGE=balenalib/raspberry-pi . 
    docker push $CIRRUS_REPO_FULL_NAME:${TAG}-armv6
linuxarmv7_docker_builder:
  env:
    DOCKERHUB_USER: ENCRYPTED[98e575fd2885ba39b429cdcd5c7bbfad8db12e0c4f391f0f58fea9952bf41c2d25a7567b52dc17bfff1faa810921f6de]
    DOCKERHUB_PASS: ENCRYPTED[2266391061fded5e8db8300e5a53276e4081eb8bdd73caf665e48c19ef3a8946b7bd7188f011ca588c3b9cdfd840e0fd]
  script: |
    export TAG=${CIRRUS_TAG:-latest}
    docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS 
    docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
    docker build -t $CIRRUS_REPO_FULL_NAME:${TAG}-armv7 --build-arg IMAGE=balenalib/raspberry-pi2 . 
    docker push $CIRRUS_REPO_FULL_NAME:${TAG}-armv7

publish_docker_builder:
  depends_on: 
    - linuxarmv6
    - linuxarmv7  
    - linuxarm64
    - linuxamd64
  env:
    DOCKER_CLI_EXPERIMENTAL: enabled
    DOCKERHUB_USER: ENCRYPTED[98e575fd2885ba39b429cdcd5c7bbfad8db12e0c4f391f0f58fea9952bf41c2d25a7567b52dc17bfff1faa810921f6de]
    DOCKERHUB_PASS: ENCRYPTED[2266391061fded5e8db8300e5a53276e4081eb8bdd73caf665e48c19ef3a8946b7bd7188f011ca588c3b9cdfd840e0fd]
  script: | 
    docker info
    export TAG=${CIRRUS_TAG:-latest}
    docker manifest create --amend $CIRRUS_REPO_FULL_NAME:${TAG} $CIRRUS_REPO_FULL_NAME:${TAG}-amd64 $CIRRUS_REPO_FULL_NAME:${TAG}-arm64 $CIRRUS_REPO_FULL_NAME:${TAG}-armv6 $CIRRUS_REPO_FULL_NAME:${TAG}-armv7
    docker manifest annotate $CIRRUS_REPO_FULL_NAME:${TAG} $CIRRUS_REPO_FULL_NAME:${TAG}-armv6 --os linux --arch arm --variant v6l
    docker manifest annotate $CIRRUS_REPO_FULL_NAME:${TAG} $CIRRUS_REPO_FULL_NAME:${TAG}-armv7 --os linux --arch arm --variant v7
    docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS 
    docker manifest push $CIRRUS_REPO_FULL_NAME:${TAG} -p

