name: Build Docker Image
run-name: Build Docker Image 
on: [push]

jobs:
  Build Docker Image:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository code
        uses: actions/checkout@v4
      - name: Install system dependencies
        run: |
          # change mirror to kku.ac.th for faster package downloading
          sudo sed -i 's@http://archive.ubuntu.com@http://mirror.kku.ac.th@g' /etc/apt/sources.list.d/ubuntu.sources
          sudo apt update && sudo apt install nodejs npm -y
      - name: Install project dependencies
        run: |
          cd accounting-ng-nuttakit
          npm install --force --legacy-peer-deps --include=dev
          npm install -g @angular/cli
      - name: Build webapp
        run: |
          cd accounting-ng-nuttakit
          # temporary change api url for development
          #sed -i 's@https://api.nuttakit.work@http://10.9.0.0:8080@g' src/environments/environment.ts
          ng build
      - name: Build docker image
        run: |
          docker build . -t accounting-frontend:latest
          
          