From 2ea3de967662f7b939458ae07616a86fdd5c8a98 Mon Sep 17 00:00:00 2001 From: ali ghorbani Date: Sun, 7 Apr 2024 17:31:29 +0330 Subject: [PATCH 1/5] Change SDK base image to alpine Signed-off-by: ali ghorbani --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 693dd8f95..48e1d4ece 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env +FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build-env LABEL stage=build-env WORKDIR /app From 2de2443d30d265c18326059afa472319b61c9984 Mon Sep 17 00:00:00 2001 From: ali ghorbani Date: Sun, 7 Apr 2024 22:39:27 +0330 Subject: [PATCH 2/5] Replace dynamic plugin build Signed-off-by: ali ghorbani --- Dockerfile | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 48e1d4ece..bc630b28b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,22 +9,12 @@ ARG GIT_COMMIT ARG GIT_BRANCH # build plugins -RUN dotnet build /app/Plugins/Authentication.Facebook -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH -RUN dotnet build /app/Plugins/Authentication.Google -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH -RUN dotnet build /app/Plugins/DiscountRules.Standard -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH -RUN dotnet build /app/Plugins/ExchangeRate.McExchange -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH -RUN dotnet build /app/Plugins/Payments.BrainTree -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH -RUN dotnet build /app/Plugins/Payments.CashOnDelivery -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH -RUN dotnet build /app/Plugins/Payments.StripeCheckout -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH -RUN dotnet build /app/Plugins/Shipping.ByWeight -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH -RUN dotnet build /app/Plugins/Shipping.FixedRateShipping -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH -RUN dotnet build /app/Plugins/Shipping.ShippingPoint -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH -RUN dotnet build /app/Plugins/Tax.CountryStateZip -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH -RUN dotnet build /app/Plugins/Tax.FixedRate -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH -RUN dotnet build /app/Plugins/Widgets.FacebookPixel -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH -RUN dotnet build /app/Plugins/Widgets.GoogleAnalytics -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH -RUN dotnet build /app/Plugins/Widgets.Slider -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH -RUN dotnet build /app/Plugins/Theme.Modern -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH +RUN set -e; \ + for dir in /app/Plugins/*; do \ + if [ -d "$dir" ]; then \ + dotnet build $dir -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH; \ + fi; \ + done # restore RUN dotnet restore /app/Web/Grand.Web/Grand.Web.csproj From 268d70fdc7e1d0d2d25605073cba7e00f63ddaec Mon Sep 17 00:00:00 2001 From: ali ghorbani Date: Sun, 7 Apr 2024 22:41:00 +0330 Subject: [PATCH 3/5] Remove unnecessary restore command Signed-off-by: ali ghorbani --- Dockerfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index bc630b28b..84cc12012 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,9 +16,6 @@ RUN set -e; \ fi; \ done -# restore -RUN dotnet restore /app/Web/Grand.Web/Grand.Web.csproj - #build RUN dotnet build /app/Web/Grand.Web/Grand.Web.csproj --no-restore -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH From dcf153413137e07885bca23ec7819953fb3e3d69 Mon Sep 17 00:00:00 2001 From: ali ghorbani Date: Sun, 7 Apr 2024 22:46:22 +0330 Subject: [PATCH 4/5] Cahnge runtime base image to alpine Signed-off-by: ali ghorbani --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 84cc12012..a540cc6d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ RUN dotnet build /app/Web/Grand.Web/Grand.Web.csproj --no-restore -c Release -p: RUN dotnet publish /app/Web/Grand.Web --no-restore -c Release -o ./build/release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH # Build runtime image -FROM mcr.microsoft.com/dotnet/aspnet:8.0 +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine3.19 EXPOSE 8080 From 9e58ad355883404b32634fdb6645ee6dcb4e6335 Mon Sep 17 00:00:00 2001 From: Ali Ghorbani Date: Mon, 6 May 2024 01:02:37 +0330 Subject: [PATCH 5/5] Update Dockerfile Change runtime image to alpine --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0a4c66a9e..951cf880c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,8 +21,8 @@ RUN dotnet build /app/Web/Grand.Web/Grand.Web.csproj --no-restore -c Release -p: RUN dotnet publish /app/Web/Grand.Web/Grand.Web.csproj -c Release -o ./build/release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH # Runtime stage -FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS runtime EXPOSE 8080 WORKDIR /app COPY --from=build-env /app/build/release . -ENTRYPOINT ["dotnet", "Grand.Web.dll"] \ No newline at end of file +ENTRYPOINT ["dotnet", "Grand.Web.dll"]