From 65ca175f980820fa1d56f7a8fcf5e73a3875a195 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Tue, 23 Jun 2026 11:38:40 +0700 Subject: [PATCH] fix Dockerfile --- BMA.EHR.CheckInConsumer/.dockerignore | 24 ++++++++++++++++++++++++ BMA.EHR.CheckInConsumer/Dockerfile | 22 ++++++++-------------- 2 files changed, 32 insertions(+), 14 deletions(-) create mode 100644 BMA.EHR.CheckInConsumer/.dockerignore diff --git a/BMA.EHR.CheckInConsumer/.dockerignore b/BMA.EHR.CheckInConsumer/.dockerignore new file mode 100644 index 00000000..741ce7d4 --- /dev/null +++ b/BMA.EHR.CheckInConsumer/.dockerignore @@ -0,0 +1,24 @@ +# Build artifacts +bin/ +obj/ + +# IDE / tooling +Properties/ +.vs/ +.vscode/ +.idea/ + +# Source control +.git/ +.gitignore + +# Documentation +*.md + +# Docker +Dockerfile +.dockerignore + +# OS files +.DS_Store +Thumbs.db diff --git a/BMA.EHR.CheckInConsumer/Dockerfile b/BMA.EHR.CheckInConsumer/Dockerfile index 1c90d6f2..314f1b71 100644 --- a/BMA.EHR.CheckInConsumer/Dockerfile +++ b/BMA.EHR.CheckInConsumer/Dockerfile @@ -1,4 +1,4 @@ -## See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. +## See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. # ## This stage is used when running from VS in fast mode (Default for Debug configuration) #FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base @@ -34,25 +34,19 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build # กำหนด working directory ภายใน container WORKDIR /src -# คัดลอกไฟล์ .csproj และ restore dependencies -# COPY *.csproj ./ -COPY . ./ -RUN dotnet restore +# copy เฉพาะ .csproj ก่อน เพื่อใช้ layer caching (restore เร็ว เก็บ cache นาน) +COPY BMA.EHR.CheckInConsumer.csproj ./ +RUN dotnet restore "BMA.EHR.CheckInConsumer.csproj" -# คัดลอกไฟล์ทั้งหมดและ build +# คัดลอก source ที่เหลือแล้ว publish 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 +RUN dotnet publish "BMA.EHR.CheckInConsumer.csproj" -c Release -o /app/publish /p:UseAppHost=false -# ใช้ stage ใหม่สำหรับการ runtime +# ใช้ stage ใหม่สำหรับ runtime (image เล็กลง) FROM mcr.microsoft.com/dotnet/runtime:8.0 AS runtime -# กำหนด working directory สำหรับ runtime WORKDIR /app -# คัดลอกไฟล์จาก build stage มายัง runtime stage -COPY --from=build /app/build . +COPY --from=build /app/publish . -# ระบุ entry point ของแอปพลิเคชัน ENTRYPOINT ["dotnet", "BMA.EHR.CheckInConsumer.dll"]