# SPDX-FileCopyrightText: 2024-2025 Sarah Vaupel <sarah.vaupel@uniworx.de>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

parameters:
  - name: services
    type: object
    default:
      - name: frontend
        base:
          image: devfra.azurecr.io/de.fraport.build/npm
          tag: node-20
        # extraBuildOptions: |
        #   --build-arg NPM_CUSTOM_REGISTRY=https://pkgs.dev.azure.com/fraport/_packaging/packages/npm/registry/
        pool: 'Prod Private Agent Pool'
        timeout: 60
        dependencies: []
        artifacts: |
          assets/icons/fradrive/*.svg
          assets/favicons/*.png
          assets/favicons/include.html
          static/**/*
          well-known/**/*
          frontend/src/env.sass
          config/manifest.json
      - name: backend
        base:
          image: devfra.azurecr.io/de.fraport.build/haskell
          tag: 8.10.4
        pool: 'Prod Private Agent Pool DS3'
        timeout: 1440
        dependencies:
          - frontend
        artifacts: |
          bin/uniworx
          bin/uniworxdb

variables:
  imageUpstream: devfra.azurecr.io/de.fraport.fradrive.build
  onMasterBranch: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')]
  onUpdateBranch: $[startsWith(variables['Build.SourceBranch'], 'refs/heads/update')]

pool: 'Prod Private Agent Pool'

stages:
- ${{ each service in parameters.services }}:
  - template: .azure-pipelines/templates/service.yaml
    parameters:
      serviceName: ${{ service.name }}
      serviceBase: ${{ service.base }}
      servicePool: ${{ service.pool }}
      serviceTimeout: ${{ service.timeout }}
      serviceDependencies: ${{ service.dependencies }}
      serviceArtifacts: ${{ service.artifacts }}