# Copyright 2022 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

steps:
# insecure builder required due to cros_sdk can only run in a privileged container
- name: 'gcr.io/cloud-builders/docker'
  args: [ 'buildx', 'create', '--use', '--name', 'insecure-builder', '--buildkitd-flags', '--allow-insecure-entitlement security.insecure']
- name: 'gcr.io/cloud-builders/docker'
  args: [ 'buildx', 'build', '-t', 'gcr.io/crosvm-infra/crosvm_cros_cloudbuild', '--cache-to=type=local,dest=/docker_cache', '--allow', 'security.insecure', '.' ]
# docker push is separated out because of https://github.com/docker/buildx/issues/1205
- name: 'gcr.io/cloud-builders/docker'
  args: [ 'buildx', 'stop', 'insecure-builder']
- name: 'gcr.io/cloud-builders/docker'
  args: [ 'buildx', 'build', '-t', 'gcr.io/crosvm-infra/crosvm_cros_cloudbuild', '--cache-from=type=local,src=/docker_cache', '--push', '--allow', 'security.insecure', '.' ]
timeout: 30000s
options:
  machineType: 'E2_HIGHCPU_32'
  diskSizeGb: '1000'
  volumes:
    - name: 'docker_cache'
      path: '/docker_cache'
