From 10196f44a80e7b0eac049fb94c85b36413cef51b Mon Sep 17 00:00:00 2001 From: Suchin Sapphasitthatha Date: Sun, 15 Dec 2024 10:39:09 +0700 Subject: [PATCH 01/10] modify dockerfile for CheckInConsumer --- BMA.EHR.CheckInConsumer/Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/BMA.EHR.CheckInConsumer/Dockerfile b/BMA.EHR.CheckInConsumer/Dockerfile index 5bab7aad..425ff61f 100644 --- a/BMA.EHR.CheckInConsumer/Dockerfile +++ b/BMA.EHR.CheckInConsumer/Dockerfile @@ -40,8 +40,10 @@ COPY . ./ RUN dotnet restore # คัดลอกไฟล์ทั้งหมดและ build -COPY . ./ -RUN dotnet build -c Release -o /app/build +# COPY . ./ +# RUN dotnet build -c Release -o /app/build +WORKDIR "/src/BMA.EHR.CheckInConsumer" +RUN dotnet build "BMA.EHR.CheckInConsumer.csproj" -c Release -o /app/build # ใช้ stage ใหม่สำหรับการ runtime FROM mcr.microsoft.com/dotnet/runtime:8.0 AS runtime @@ -53,4 +55,4 @@ WORKDIR /app COPY --from=build /app/build . # ระบุ entry point ของแอปพลิเคชัน -ENTRYPOINT ["dotnet", "BMA.EHR.CheckInConsumer.dll"] \ No newline at end of file +ENTRYPOINT ["dotnet", "BMA.EHR.CheckInConsumer.dll"] From 76ddcfc6146806f9390bdbc054d7e67137fedb1d Mon Sep 17 00:00:00 2001 From: Suchin Sapphasitthatha Date: Sun, 15 Dec 2024 09:29:56 +0000 Subject: [PATCH 02/10] modify CI to include build leave api --- .onedev-buildspec.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.onedev-buildspec.yml b/.onedev-buildspec.yml index 91d7f220..ddcfad0a 100644 --- a/.onedev-buildspec.yml +++ b/.onedev-buildspec.yml @@ -1,6 +1,6 @@ version: 37 jobs: -- name: CI for Checkin [UAT] +- name: CI for CheckinLeave [UAT] steps: - !CheckoutStep name: checkout code @@ -33,29 +33,35 @@ jobs: dotnet test -l trx --collect:"XPlat Code Coverage" #/root/.dotnet/tools/roslynator analyze -o roslynator-analysis.xml useTTY: true - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + condition: NEVER - !PublishTRXReportStep name: publish unit test report reportName: Unit Test filePatterns: '**/*.trx' - condition: ALWAYS + condition: NEVER - !PublishCoberturaReportStep name: publish code coverage report reportName: Code Coverage filePatterns: '**/coverage.cobertura.xml' - condition: ALWAYS + condition: NEVER - !PublishRoslynatorReportStep name: publish code problem report reportName: Code Problems filePatterns: roslynator-analysis.xml failThreshold: HIGH - condition: ALWAYS + condition: NEVER - !SetBuildVersionStep name: set build version buildVersion: '@tag@' condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - !BuildImageStep - name: build docker image + name: build docker image - Leave + dockerfile: ./BMA.EHR.Leave/Dockerfile + output: !RegistryOutput + tags: hrms-git.chin.in.th/bma-hrms/hrms-api-leave:@build_version@ hrms-git.chin.in.th/bma-hrms/hrms-api-leave:latest + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !BuildImageStep + name: build docker image - Checkin dockerfile: ./BMA.EHR.CheckInConsumer/Dockerfile output: !RegistryOutput tags: hrms-git.chin.in.th/bma-hrms/hrms-api-checkin:@build_version@ hrms-git.chin.in.th/bma-hrms/hrms-api-checkin:latest From 3e4299fb4cf20650cea335ce126a1a57b3991b42 Mon Sep 17 00:00:00 2001 From: Suchin Sapphasitthatha Date: Sun, 15 Dec 2024 17:56:38 +0700 Subject: [PATCH 03/10] Test Change Docker file for Leave --- BMA.EHR.Leave/Dockerfile | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/BMA.EHR.Leave/Dockerfile b/BMA.EHR.Leave/Dockerfile index a6899e01..8cd9e73b 100644 --- a/BMA.EHR.Leave/Dockerfile +++ b/BMA.EHR.Leave/Dockerfile @@ -8,15 +8,27 @@ EXPOSE 443 FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build WORKDIR /src -COPY ["BMA.EHR.Domain/BMA.EHR.Domain.csproj", "BMA.EHR.Domain/"] -COPY ["BMA.EHR.Application/BMA.EHR.Application.csproj", "BMA.EHR.Application/"] -COPY ["BMA.EHR.Infrastructure/BMA.EHR.Infrastructure.csproj", "BMA.EHR.Infrastructure/"] -COPY ["BMA.EHR.Leave/BMA.EHR.Leave.csproj", "BMA.EHR.Leave/"] +# -- BEGIN: Old Build -- +# COPY ["BMA.EHR.Domain/BMA.EHR.Domain.csproj", "BMA.EHR.Domain/"] +# COPY ["BMA.EHR.Application/BMA.EHR.Application.csproj", "BMA.EHR.Application/"] +# COPY ["BMA.EHR.Infrastructure/BMA.EHR.Infrastructure.csproj", "BMA.EHR.Infrastructure/"] +# COPY ["BMA.EHR.Leave/BMA.EHR.Leave.csproj", "BMA.EHR.Leave/"] -RUN dotnet restore "BMA.EHR.Leave/BMA.EHR.Leave.csproj" -COPY . . +# RUN dotnet restore "BMA.EHR.Leave/BMA.EHR.Leave.csproj" +# COPY . . +# WORKDIR "/src/BMA.EHR.Leave" +# RUN dotnet build "BMA.EHR.Leave.csproj" -c Release -o /app/build +# -- END: Old Build -- + +# -- BEGIN: Test New Build -- +# คัดลอกไฟล์ .csproj และ restore dependencies +COPY . ./ +RUN dotnet restore + +# คัดลอกไฟล์ทั้งหมดและ build WORKDIR "/src/BMA.EHR.Leave" -RUN dotnet build "BMA.EHR.Leave.csproj" -c Release -o /app/build +RUN dotnet build "BMA.EHR.Leave.csproj" -c Release -o /app/build +# -- END: Test New Build FROM build AS publish RUN dotnet publish "BMA.EHR.Leave.csproj" -c Release -o /app/publish /p:UseAppHost=false @@ -24,4 +36,4 @@ RUN dotnet publish "BMA.EHR.Leave.csproj" -c Release -o /app/publish /p:UseAppHo FROM base AS final WORKDIR /app COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "BMA.EHR.Leave.dll"] \ No newline at end of file +ENTRYPOINT ["dotnet", "BMA.EHR.Leave.dll"] From ae3d705187c0853b5c37f0b41fd30078135b562d Mon Sep 17 00:00:00 2001 From: Suchin Sapphasitthatha Date: Sun, 15 Dec 2024 18:10:49 +0700 Subject: [PATCH 04/10] exp: test dockerfile again --- BMA.EHR.Leave/Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/BMA.EHR.Leave/Dockerfile b/BMA.EHR.Leave/Dockerfile index 8cd9e73b..8ece9365 100644 --- a/BMA.EHR.Leave/Dockerfile +++ b/BMA.EHR.Leave/Dockerfile @@ -21,8 +21,10 @@ WORKDIR /src # -- END: Old Build -- # -- BEGIN: Test New Build -- -# คัดลอกไฟล์ .csproj และ restore dependencies -COPY . ./ +COPY ["BMA.EHR.Domain/BMA.EHR.Domain.csproj", "BMA.EHR.Domain/"] +COPY ["BMA.EHR.Application/BMA.EHR.Application.csproj", "BMA.EHR.Application/"] +COPY ["BMA.EHR.Infrastructure/BMA.EHR.Infrastructure.csproj", "BMA.EHR.Infrastructure/"] +COPY ["BMA.EHR.Leave/BMA.EHR.Leave.csproj", "BMA.EHR.Leave/"] RUN dotnet restore # คัดลอกไฟล์ทั้งหมดและ build From 00c2370b19382694700321cf6ec59ffdba170285 Mon Sep 17 00:00:00 2001 From: Suchin Sapphasitthatha Date: Sun, 15 Dec 2024 18:25:56 +0700 Subject: [PATCH 05/10] exp: test dockerfile --- BMA.EHR.Leave/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BMA.EHR.Leave/Dockerfile b/BMA.EHR.Leave/Dockerfile index 8ece9365..208f9b00 100644 --- a/BMA.EHR.Leave/Dockerfile +++ b/BMA.EHR.Leave/Dockerfile @@ -25,7 +25,7 @@ COPY ["BMA.EHR.Domain/BMA.EHR.Domain.csproj", "BMA.EHR.Domain/"] COPY ["BMA.EHR.Application/BMA.EHR.Application.csproj", "BMA.EHR.Application/"] COPY ["BMA.EHR.Infrastructure/BMA.EHR.Infrastructure.csproj", "BMA.EHR.Infrastructure/"] COPY ["BMA.EHR.Leave/BMA.EHR.Leave.csproj", "BMA.EHR.Leave/"] -RUN dotnet restore +RUN dotnet restore "BMA.EHR.Leave/BMA.EHR.Leave.csproj" # คัดลอกไฟล์ทั้งหมดและ build WORKDIR "/src/BMA.EHR.Leave" From af420225d844b0f3d8d65d572736b0d700810fe2 Mon Sep 17 00:00:00 2001 From: Suchin Sapphasitthatha Date: Sun, 15 Dec 2024 18:48:31 +0700 Subject: [PATCH 06/10] exp: test dockerfile --- BMA.EHR.Leave/Dockerfile | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/BMA.EHR.Leave/Dockerfile b/BMA.EHR.Leave/Dockerfile index 208f9b00..96460406 100644 --- a/BMA.EHR.Leave/Dockerfile +++ b/BMA.EHR.Leave/Dockerfile @@ -21,13 +21,8 @@ WORKDIR /src # -- END: Old Build -- # -- BEGIN: Test New Build -- -COPY ["BMA.EHR.Domain/BMA.EHR.Domain.csproj", "BMA.EHR.Domain/"] -COPY ["BMA.EHR.Application/BMA.EHR.Application.csproj", "BMA.EHR.Application/"] -COPY ["BMA.EHR.Infrastructure/BMA.EHR.Infrastructure.csproj", "BMA.EHR.Infrastructure/"] -COPY ["BMA.EHR.Leave/BMA.EHR.Leave.csproj", "BMA.EHR.Leave/"] +COPY . ./ RUN dotnet restore "BMA.EHR.Leave/BMA.EHR.Leave.csproj" - -# คัดลอกไฟล์ทั้งหมดและ build WORKDIR "/src/BMA.EHR.Leave" RUN dotnet build "BMA.EHR.Leave.csproj" -c Release -o /app/build # -- END: Test New Build From a1815ed7e7249586ffac1a2ef11bdf04a12de787 Mon Sep 17 00:00:00 2001 From: Suchin Sapphasitthatha Date: Sun, 15 Dec 2024 19:29:56 +0700 Subject: [PATCH 07/10] exp: test sdk 8 --- BMA.EHR.Leave/Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/BMA.EHR.Leave/Dockerfile b/BMA.EHR.Leave/Dockerfile index 96460406..af920212 100644 --- a/BMA.EHR.Leave/Dockerfile +++ b/BMA.EHR.Leave/Dockerfile @@ -5,7 +5,7 @@ WORKDIR /app EXPOSE 80 EXPOSE 443 -FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /src # -- BEGIN: Old Build -- @@ -21,7 +21,10 @@ WORKDIR /src # -- END: Old Build -- # -- BEGIN: Test New Build -- -COPY . ./ +COPY ["BMA.EHR.Domain/BMA.EHR.Domain.csproj", "BMA.EHR.Domain/"] +COPY ["BMA.EHR.Application/BMA.EHR.Application.csproj", "BMA.EHR.Application/"] +COPY ["BMA.EHR.Infrastructure/BMA.EHR.Infrastructure.csproj", "BMA.EHR.Infrastructure/"] +COPY ["BMA.EHR.Leave/BMA.EHR.Leave.csproj", "BMA.EHR.Leave/"] RUN dotnet restore "BMA.EHR.Leave/BMA.EHR.Leave.csproj" WORKDIR "/src/BMA.EHR.Leave" RUN dotnet build "BMA.EHR.Leave.csproj" -c Release -o /app/build From 035395f5a56b66beacce64315fa4dc043c5797ce Mon Sep 17 00:00:00 2001 From: Suchin Sapphasitthatha Date: Mon, 16 Dec 2024 09:14:06 +0000 Subject: [PATCH 08/10] disable CI --- .onedev-buildspec.yml | 54 ++----------------------------------------- 1 file changed, 2 insertions(+), 52 deletions(-) diff --git a/.onedev-buildspec.yml b/.onedev-buildspec.yml index ddcfad0a..d5e0a732 100644 --- a/.onedev-buildspec.yml +++ b/.onedev-buildspec.yml @@ -59,13 +59,13 @@ jobs: dockerfile: ./BMA.EHR.Leave/Dockerfile output: !RegistryOutput tags: hrms-git.chin.in.th/bma-hrms/hrms-api-leave:@build_version@ hrms-git.chin.in.th/bma-hrms/hrms-api-leave:latest - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + condition: NEVER - !BuildImageStep name: build docker image - Checkin dockerfile: ./BMA.EHR.CheckInConsumer/Dockerfile output: !RegistryOutput tags: hrms-git.chin.in.th/bma-hrms/hrms-api-checkin:@build_version@ hrms-git.chin.in.th/bma-hrms/hrms-api-checkin:latest - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + condition: NEVER triggers: - !TagCreateTrigger tags: uat-* @@ -74,53 +74,3 @@ jobs: maxRetries: 3 retryDelay: 30 timeout: 14400 -- name: CI for PROD - steps: - - !CheckoutStep - name: checkout code - cloneCredential: !DefaultCredential {} - withLfs: false - withSubmodules: false - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - - !GenerateChecksumStep - name: generate package checksum - files: package-lock.json yarn.lock - targetFile: checksum - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - - !SetupCacheStep - name: set up npm cache - key: node_modules_@file:checksum@ - loadKeys: - - node_modules - paths: - - node_modules - uploadStrategy: UPLOAD_IF_NOT_HIT - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - - !SetBuildVersionStep - name: set build version - buildVersion: '@tag@' - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - - !CommandStep - name: build & test - runInContainer: true - image: node - interpreter: !DefaultInterpreter - commands: | - npm install - npm run build - useTTY: true - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - - !BuildImageStep - name: build docker image - dockerfile: ./docker/Dockerfile - output: !RegistryOutput - tags: hrms-git.bangkok.go.th/bma-hrms/hrms-api-checkin:@build_version@ hrms-git.bangkok.go.th/bma-hrms/hrms-api-checkin:latest - condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - triggers: - - !TagCreateTrigger - tags: prod-* - branches: main - retryCondition: never - maxRetries: 3 - retryDelay: 30 - timeout: 14400 From 1afe331397d8a4f5cfc8e31d6e30e8a516ecb494 Mon Sep 17 00:00:00 2001 From: Suchin Sapphasitthatha Date: Mon, 16 Dec 2024 16:15:47 +0700 Subject: [PATCH 09/10] Reverse CI for CheckIn & Leave --- BMA.EHR.CheckInConsumer/Dockerfile | 8 ++++---- BMA.EHR.Leave/Dockerfile | 20 ++++---------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/BMA.EHR.CheckInConsumer/Dockerfile b/BMA.EHR.CheckInConsumer/Dockerfile index 425ff61f..1c90d6f2 100644 --- a/BMA.EHR.CheckInConsumer/Dockerfile +++ b/BMA.EHR.CheckInConsumer/Dockerfile @@ -40,10 +40,10 @@ COPY . ./ RUN dotnet restore # คัดลอกไฟล์ทั้งหมดและ build -# COPY . ./ -# RUN dotnet build -c Release -o /app/build -WORKDIR "/src/BMA.EHR.CheckInConsumer" -RUN dotnet build "BMA.EHR.CheckInConsumer.csproj" -c Release -o /app/build +COPY . ./ +RUN dotnet build -c Release -o /app/build +# WORKDIR "/src/BMA.EHR.CheckInConsumer" +# RUN dotnet build "BMA.EHR.CheckInConsumer.csproj" -c Release -o /app/build # ใช้ stage ใหม่สำหรับการ runtime FROM mcr.microsoft.com/dotnet/runtime:8.0 AS runtime diff --git a/BMA.EHR.Leave/Dockerfile b/BMA.EHR.Leave/Dockerfile index af920212..3c211ab3 100644 --- a/BMA.EHR.Leave/Dockerfile +++ b/BMA.EHR.Leave/Dockerfile @@ -5,30 +5,18 @@ WORKDIR /app EXPOSE 80 EXPOSE 443 -FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build WORKDIR /src -# -- BEGIN: Old Build -- -# COPY ["BMA.EHR.Domain/BMA.EHR.Domain.csproj", "BMA.EHR.Domain/"] -# COPY ["BMA.EHR.Application/BMA.EHR.Application.csproj", "BMA.EHR.Application/"] -# COPY ["BMA.EHR.Infrastructure/BMA.EHR.Infrastructure.csproj", "BMA.EHR.Infrastructure/"] -# COPY ["BMA.EHR.Leave/BMA.EHR.Leave.csproj", "BMA.EHR.Leave/"] - -# RUN dotnet restore "BMA.EHR.Leave/BMA.EHR.Leave.csproj" -# COPY . . -# WORKDIR "/src/BMA.EHR.Leave" -# RUN dotnet build "BMA.EHR.Leave.csproj" -c Release -o /app/build -# -- END: Old Build -- - -# -- BEGIN: Test New Build -- COPY ["BMA.EHR.Domain/BMA.EHR.Domain.csproj", "BMA.EHR.Domain/"] COPY ["BMA.EHR.Application/BMA.EHR.Application.csproj", "BMA.EHR.Application/"] COPY ["BMA.EHR.Infrastructure/BMA.EHR.Infrastructure.csproj", "BMA.EHR.Infrastructure/"] COPY ["BMA.EHR.Leave/BMA.EHR.Leave.csproj", "BMA.EHR.Leave/"] + RUN dotnet restore "BMA.EHR.Leave/BMA.EHR.Leave.csproj" +COPY . . WORKDIR "/src/BMA.EHR.Leave" -RUN dotnet build "BMA.EHR.Leave.csproj" -c Release -o /app/build -# -- END: Test New Build +RUN dotnet build "BMA.EHR.Leave.csproj" -c Release -o /app/build FROM build AS publish RUN dotnet publish "BMA.EHR.Leave.csproj" -c Release -o /app/publish /p:UseAppHost=false From 6b2348f07093de4d4cbf90780acd918397e344b7 Mon Sep 17 00:00:00 2001 From: Suchin Sapphasitthatha Date: Mon, 16 Dec 2024 09:17:05 +0000 Subject: [PATCH 10/10] add Insignia CI --- .onedev-buildspec.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.onedev-buildspec.yml b/.onedev-buildspec.yml index d5e0a732..bd58b796 100644 --- a/.onedev-buildspec.yml +++ b/.onedev-buildspec.yml @@ -1,6 +1,6 @@ version: 37 jobs: -- name: CI for CheckinLeave [UAT] +- name: CI for UAT steps: - !CheckoutStep name: checkout code @@ -66,6 +66,12 @@ jobs: output: !RegistryOutput tags: hrms-git.chin.in.th/bma-hrms/hrms-api-checkin:@build_version@ hrms-git.chin.in.th/bma-hrms/hrms-api-checkin:latest condition: NEVER + - !BuildImageStep + name: build docker image - Insignia + dockerfile: ./BMA.EHR.Insignia/Dockerfile + output: !RegistryOutput + tags: hrms-git.chin.in.th/bma-hrms/hrms-api-insignia:@build_version@ hrms-git.chin.in.th/bma-hrms/hrms-api-insignia:latest + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL triggers: - !TagCreateTrigger tags: uat-*