Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Refactor Dockerfile to use a loop for building plugins and publish Web project

supporte052ba47b546
diff --git a/Dockerfile b/Dockerfile
index 693dd8f95..13952466e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,45 +1,25 @@
+# Build stage
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
LABEL stage=build-env
WORKDIR /app
-# Copy and build
-COPY ./src /app
+# Copy
+COPY ./src/ /app/
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
+# Build plugins
+RUN for plugin in /app/Plugins/*; do \
+ dotnet build "$plugin" -c Release -p:SourceRevisionId=$GIT_COMMIT -p:GitBranch=$GIT_BRANCH; \
+ 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
-
-# publish Web
-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
+# Publish Web project
+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
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"]