name: Build

on:
  pull_request:
  push:
    branches-ignore:
      - 'hotfix-*'   
      - 'release'


jobs:

  docker-build-accounts:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4

      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun
      
      # build image for accounts service
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./Accounts/Dockerfile .

  docker-build-isolated-vm:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4

      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun
      
      # build image for accounts service
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./IsolatedVM/Dockerfile .

  docker-build-home:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4

      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun
      
      # build image for accounts service
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./Home/Dockerfile .

  docker-build-worker:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4

      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun
      
      # build image for accounts service
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./Worker/Dockerfile .

  docker-build-workflow:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4

      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun
      
      # build image for accounts service
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./Workflow/Dockerfile .

  docker-build-api-reference:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4

      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun
      
      # build image for accounts service
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./APIReference/Dockerfile .

  docker-build-docs:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4

      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun
      
      # build image for accounts service
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./Docs/Dockerfile .


  docker-build-otel-collector:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4

      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun
      
      # build image for accounts service
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./OTelCollector/Dockerfile .

  docker-build-app:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4

      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun

        
      # build image for accounts service
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./App/Dockerfile .


  docker-build-copilot:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4

      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun

      # build image for accounts service
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./Copilot/Dockerfile .

  docker-build-e2e:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4

      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun

        
      # build image for accounts service
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./E2E/Dockerfile .

  docker-build-admin-dashboard:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4

      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun

      # build image for home
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./AdminDashboard/Dockerfile .

  docker-build-dashboard:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4

      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun

      # build image for home
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./Dashboard/Dockerfile .

  docker-build-probe:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4
      
      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun
        
      # build image probe api
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./Probe/Dockerfile .

  docker-build-probe-ingest:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4
      
      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun
        
      # build image probe api
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./ProbeIngest/Dockerfile .

  docker-build-server-monitor-ingest:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4
      
      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun
        
      # build image probe api
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./ServerMonitorIngest/Dockerfile .

  docker-build-telemetry:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4
      
      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun
        
      # build image probe api
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./Telemetry/Dockerfile .

  docker-build-incoming-request-ingest:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4
      
      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun
        
      # build image probe api
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./IncomingRequestIngest/Dockerfile .

  docker-build-status-page:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4

      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun
        
      # build image for home
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./StatusPage/Dockerfile .

  docker-build-test-server:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - name: Checkout 
        uses: actions/checkout@v4

      - name: Preinstall 
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: npm run prerun

      # build image for mail service
      - name: build docker image
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 45
          max_attempts: 3
          command: sudo docker build --no-cache -f ./TestServer/Dockerfile .
