# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Build containers with tags.
# Must be used with Cloud Build's "Push new tag" Events

steps:
  - id: client build
    name: "gcr.io/cloud-builders/docker"
    dir: client
    args:
      - build
      - --build-arg
      - PROJECT_ID=$PROJECT_ID
      - --build-arg
      - AVOCANO_PURCHASE_MODE=$_PURCHASE_MODE
      - "-t"
      - us-docker.pkg.dev/$PROJECT_ID/containers/$_CLIENT_IMAGE_NAME:$TAG_NAME
      - "."

  - id: server build
    name: buildpacksio/pack
    args:
      - build
      - us-docker.pkg.dev/$PROJECT_ID/containers/$_SERVER_IMAGE_NAME:$TAG_NAME
      - --builder=gcr.io/buildpacks/builder:v1
      - --path=server/


images:
  - us-docker.pkg.dev/$PROJECT_ID/containers/$_CLIENT_IMAGE_NAME:$TAG_NAME
  - us-docker.pkg.dev/$PROJECT_ID/containers/$_SERVER_IMAGE_NAME:$TAG_NAME

substitutions:
  _CLIENT_IMAGE_NAME: client
  _SERVER_IMAGE_NAME: server
  _PURCHASE_MODE: ""

options:
  dynamic_substitutions: true
