From 9b74d3daa015d3be819360e32ccaabb8ae60a487 Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Thu, 23 Mar 2017 12:20:03 -0400 Subject: [PATCH 1/6] chmod +x on the git index for build-bits.sh --- cli-mac/build-bits.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 cli-mac/build-bits.sh diff --git a/cli-mac/build-bits.sh b/cli-mac/build-bits.sh old mode 100644 new mode 100755 From 6077f139d541c0447c951d08715e3139698d2f01 Mon Sep 17 00:00:00 2001 From: Matt Ward <(none)> Date: Sun, 16 Jul 2017 12:05:01 +0100 Subject: [PATCH 2/6] Configure packages directory for restored NuGet packages All solutions now restore to the packages directory at the root of the repository. This fixes packages being restored into the src/Mobile/packages directory when the eShopOnContainers.Xamarin.sln is opened. --- NuGet.config | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NuGet.config b/NuGet.config index ae7699939..da29646ef 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,5 +1,8 @@  + + + From 091ed81e7bf3179344fe74e8135f3e1e866d4f94 Mon Sep 17 00:00:00 2001 From: yanchenw Date: Mon, 27 Nov 2017 13:48:31 -0800 Subject: [PATCH 3/6] Converts to use multi-stage build Dockerfile 1. Changes the build context of all services to the root level to be able to access the dependencies for each project. 2. Commented out the prepublish scripts, these steps are moved into the Dockerfile Did not change any script yet, need help to identify what scripts we need to change. --- .dockerignore | 24 +++++++++++ docker-compose.dcproj | 1 + docker-compose.yml | 40 +++++++++---------- src/Services/Basket/Basket.API/.dockerignore | 3 -- .../Basket/Basket.API/Basket.API.csproj | 9 ----- src/Services/Basket/Basket.API/Dockerfile | 25 ++++++++++-- .../Catalog/Catalog.API/.dockerignore | 3 -- .../Catalog/Catalog.API/Catalog.API.csproj | 3 -- src/Services/Catalog/Catalog.API/Dockerfile | 29 ++++++++++++-- .../Identity/Identity.API/.dockerignore | 3 -- src/Services/Identity/Identity.API/Dockerfile | 25 ++++++++++-- .../Identity/Identity.API/Identity.API.csproj | 3 -- .../Location/Locations.API/.dockerignore | 3 -- .../Location/Locations.API/Dockerfile | 25 ++++++++++-- .../Marketing/Marketing.API/.dockerignore | 3 -- .../Marketing/Marketing.API/Dockerfile | 27 +++++++++++-- .../Marketing.API/Marketing.API.csproj | 3 -- .../Ordering/Ordering.API/.dockerignore | 3 -- src/Services/Ordering/Ordering.API/Dockerfile | 30 ++++++++++++-- .../Ordering/Ordering.API/Ordering.API.csproj | 6 --- .../Payment/Payment.API/.dockerignore | 3 -- src/Services/Payment/Payment.API/Dockerfile | 27 +++++++++++-- .../Catalog.WebForms/Catalog.WebForms.csproj | 3 -- src/Web/WebMVC/.dockerignore | 3 -- src/Web/WebMVC/Dockerfile | 26 ++++++++++-- src/Web/WebMVC/WebMVC.csproj | 12 ++---- src/Web/WebMonolithic/eShopWeb/.dockerignore | 3 -- src/Web/WebSPA/.dockerignore | 3 -- src/Web/WebSPA/Dockerfile | 26 ++++++++++-- src/Web/WebSPA/WebSPA.csproj | 10 +---- src/Web/WebSPA/package-lock.json | 30 +++++++------- src/Web/WebStatus/.dockerignore | 3 -- src/Web/WebStatus/Dockerfile | 22 ++++++++-- 33 files changed, 297 insertions(+), 142 deletions(-) create mode 100644 .dockerignore delete mode 100644 src/Services/Basket/Basket.API/.dockerignore delete mode 100644 src/Services/Catalog/Catalog.API/.dockerignore delete mode 100644 src/Services/Identity/Identity.API/.dockerignore delete mode 100644 src/Services/Location/Locations.API/.dockerignore delete mode 100644 src/Services/Marketing/Marketing.API/.dockerignore delete mode 100644 src/Services/Ordering/Ordering.API/.dockerignore delete mode 100644 src/Services/Payment/Payment.API/.dockerignore delete mode 100644 src/Web/WebMVC/.dockerignore delete mode 100644 src/Web/WebMonolithic/eShopWeb/.dockerignore delete mode 100644 src/Web/WebSPA/.dockerignore delete mode 100644 src/Web/WebStatus/.dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..37e211fa2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,24 @@ +.dockerignore +.env +.git +.gitignore +.vs +.vscode +docker-compose.yml +docker-compose.*.yml +vsts-docs +test +ServiceFabric +readme +k8s +img +docs +deploy +Components +cli-windows +cli-mac +cli-linux +**/bin/ +**/obj/ +**/node_modules/ +**/bower_components/ \ No newline at end of file diff --git a/docker-compose.dcproj b/docker-compose.dcproj index 23547b577..ccdc2195a 100644 --- a/docker-compose.dcproj +++ b/docker-compose.dcproj @@ -9,6 +9,7 @@ 2.0 + docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml index 1c854c998..f37277bc3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,8 +5,8 @@ services: basket.api: image: eshop/basket.api:${TAG:-latest} build: - context: ./src/Services/Basket/Basket.API - dockerfile: Dockerfile + context: . + dockerfile: ./src/Services/Basket/Basket.API/Dockerfile depends_on: - basket.data - identity.api @@ -15,8 +15,8 @@ services: catalog.api: image: eshop/catalog.api:${TAG:-latest} build: - context: ./src/Services/Catalog/Catalog.API - dockerfile: Dockerfile + context: . + dockerfile: ./src/Services/Catalog/Catalog.API/Dockerfile depends_on: - sql.data - rabbitmq @@ -24,16 +24,16 @@ services: identity.api: image: eshop/identity.api:${TAG:-latest} build: - context: ./src/Services/Identity/Identity.API - dockerfile: Dockerfile + context: . + dockerfile: ./src/Services/Identity/Identity.API/Dockerfile depends_on: - sql.data ordering.api: image: eshop/ordering.api:${TAG:-latest} build: - context: ./src/Services/Ordering/Ordering.API - dockerfile: Dockerfile + context: . + dockerfile: ./src/Services/Ordering/Ordering.API/Dockerfile depends_on: - sql.data - rabbitmq @@ -41,8 +41,8 @@ services: marketing.api: image: eshop/marketing.api:${TAG:-latest} build: - context: ./src/Services/Marketing/Marketing.API - dockerfile: Dockerfile + context: . + dockerfile: ./src/Services/Marketing/Marketing.API/Dockerfile depends_on: - sql.data - nosql.data @@ -52,8 +52,8 @@ services: webspa: image: eshop/webspa:${TAG:-latest} build: - context: ./src/Web/WebSPA - dockerfile: Dockerfile + context: . + dockerfile: ./src/Web/WebSPA/Dockerfile depends_on: - catalog.api - ordering.api @@ -64,8 +64,8 @@ services: webmvc: image: eshop/webmvc:${TAG:-latest} build: - context: ./src/Web/WebMVC - dockerfile: Dockerfile + context: . + dockerfile: ./src/Web/WebMVC/Dockerfile depends_on: - catalog.api - ordering.api @@ -76,22 +76,22 @@ services: webstatus: image: eshop/webstatus:${TAG:-latest} build: - context: ./src/Web/WebStatus - dockerfile: Dockerfile + context: . + dockerfile: ./src/Web/WebStatus/Dockerfile payment.api: image: eshop/payment.api:${TAG:-latest} build: - context: ./src/Services/Payment/Payment.API - dockerfile: Dockerfile + context: . + dockerfile: ./src/Services/Payment/Payment.API/Dockerfile depends_on: - rabbitmq locations.api: image: eshop/locations.api:${TAG:-latest} build: - context: ./src/Services/Location/Locations.API - dockerfile: Dockerfile + context: . + dockerfile: ./src/Services/Location/Locations.API/Dockerfile depends_on: - nosql.data - rabbitmq diff --git a/src/Services/Basket/Basket.API/.dockerignore b/src/Services/Basket/Basket.API/.dockerignore deleted file mode 100644 index d8f8175f6..000000000 --- a/src/Services/Basket/Basket.API/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!obj/Docker/publish/* -!obj/Docker/empty/ diff --git a/src/Services/Basket/Basket.API/Basket.API.csproj b/src/Services/Basket/Basket.API/Basket.API.csproj index 48d32de2a..f0ae48824 100644 --- a/src/Services/Basket/Basket.API/Basket.API.csproj +++ b/src/Services/Basket/Basket.API/Basket.API.csproj @@ -10,9 +10,6 @@ PreserveNewest - - PreserveNewest - @@ -33,10 +30,4 @@ - - - Always - - - diff --git a/src/Services/Basket/Basket.API/Dockerfile b/src/Services/Basket/Basket.API/Dockerfile index 2e7395520..5e479cde0 100644 --- a/src/Services/Basket/Basket.API/Dockerfile +++ b/src/Services/Basket/Basket.API/Dockerfile @@ -1,6 +1,25 @@ -FROM microsoft/aspnetcore:2.0 -ARG source +FROM microsoft/aspnetcore:2.0 AS base WORKDIR /app EXPOSE 80 -COPY ${source:-obj/Docker/publish} . + +FROM microsoft/aspnetcore-build:2.0 AS build +WORKDIR /src +COPY eShopOnContainers-ServicesAndWebApps.sln ./ +COPY src/Services/Basket/Basket.API/Basket.API.csproj src/Services/Basket/Basket.API/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/Microsoft.AspNetCore.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Microsoft.Extensions.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/ +COPY src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj src/BuildingBlocks/EventBus/EventBusRabbitMQ/ +COPY src/BuildingBlocks/EventBus/EventBus/EventBus.csproj src/BuildingBlocks/EventBus/EventBus/ +COPY src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj src/BuildingBlocks/EventBus/EventBusServiceBus/ +RUN dotnet restore +COPY . . +WORKDIR /src/src/Services/Basket/Basket.API +RUN dotnet build -c Release -o /app + +FROM build AS publish +RUN dotnet publish -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . ENTRYPOINT ["dotnet", "Basket.API.dll"] diff --git a/src/Services/Catalog/Catalog.API/.dockerignore b/src/Services/Catalog/Catalog.API/.dockerignore deleted file mode 100644 index d8f8175f6..000000000 --- a/src/Services/Catalog/Catalog.API/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!obj/Docker/publish/* -!obj/Docker/empty/ diff --git a/src/Services/Catalog/Catalog.API/Catalog.API.csproj b/src/Services/Catalog/Catalog.API/Catalog.API.csproj index f5aec67ad..05d2ff61c 100644 --- a/src/Services/Catalog/Catalog.API/Catalog.API.csproj +++ b/src/Services/Catalog/Catalog.API/Catalog.API.csproj @@ -61,9 +61,6 @@ - - Always - PreserveNewest diff --git a/src/Services/Catalog/Catalog.API/Dockerfile b/src/Services/Catalog/Catalog.API/Dockerfile index 0f5d934d2..498263786 100644 --- a/src/Services/Catalog/Catalog.API/Dockerfile +++ b/src/Services/Catalog/Catalog.API/Dockerfile @@ -1,6 +1,29 @@ -FROM microsoft/aspnetcore:2.0 -ARG source +FROM microsoft/aspnetcore:2.0 AS base WORKDIR /app EXPOSE 80 -COPY ${source:-obj/Docker/publish} . + +FROM microsoft/aspnetcore-build:2.0 AS build +WORKDIR /src +COPY eShopOnContainers-ServicesAndWebApps.sln ./ +COPY src/Services/Catalog/Catalog.API/Catalog.API.csproj src/Services/Catalog/Catalog.API/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/Microsoft.AspNetCore.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Microsoft.Extensions.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/ +COPY src/BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj src/BuildingBlocks/EventBus/IntegrationEventLogEF/ +COPY src/BuildingBlocks/EventBus/EventBus/EventBus.csproj src/BuildingBlocks/EventBus/EventBus/ +COPY src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj src/BuildingBlocks/EventBus/EventBusRabbitMQ/ +COPY src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj src/BuildingBlocks/EventBus/EventBusServiceBus/ +COPY src/BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj src/BuildingBlocks/WebHostCustomization/WebHost.Customization/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.SqlServer/Microsoft.Extensions.HealthChecks.SqlServer.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.SqlServer/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.AzureStorage/Microsoft.Extensions.HealthChecks.AzureStorage.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.AzureStorage/ +RUN dotnet restore +COPY . . +WORKDIR /src/src/Services/Catalog/Catalog.API +RUN dotnet build -c Release -o /app + +FROM build AS publish +RUN dotnet publish -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . ENTRYPOINT ["dotnet", "Catalog.API.dll"] diff --git a/src/Services/Identity/Identity.API/.dockerignore b/src/Services/Identity/Identity.API/.dockerignore deleted file mode 100644 index d8f8175f6..000000000 --- a/src/Services/Identity/Identity.API/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!obj/Docker/publish/* -!obj/Docker/empty/ diff --git a/src/Services/Identity/Identity.API/Dockerfile b/src/Services/Identity/Identity.API/Dockerfile index 029b5893e..e50625cf2 100644 --- a/src/Services/Identity/Identity.API/Dockerfile +++ b/src/Services/Identity/Identity.API/Dockerfile @@ -1,6 +1,25 @@ -FROM microsoft/aspnetcore:2.0.0 -ARG source +FROM microsoft/aspnetcore:2.0 AS base WORKDIR /app EXPOSE 80 -COPY ${source:-obj/Docker/publish} . + +FROM microsoft/aspnetcore-build:2.0 AS build +WORKDIR /src +COPY eShopOnContainers-ServicesAndWebApps.sln ./ +COPY src/Services/Identity/Identity.API/Identity.API.csproj src/Services/Identity/Identity.API/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/Microsoft.AspNetCore.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Microsoft.Extensions.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/ +COPY src/BuildingBlocks/DataProtection/DataProtection/DataProtection.csproj src/BuildingBlocks/DataProtection/DataProtection/ +COPY src/BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj src/BuildingBlocks/WebHostCustomization/WebHost.Customization/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.SqlServer/Microsoft.Extensions.HealthChecks.SqlServer.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.SqlServer/ +RUN dotnet restore +COPY . . +WORKDIR /src/src/Services/Identity/Identity.API +RUN dotnet build -c Release -o /app + +FROM build AS publish +RUN dotnet publish -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . ENTRYPOINT ["dotnet", "Identity.API.dll"] diff --git a/src/Services/Identity/Identity.API/Identity.API.csproj b/src/Services/Identity/Identity.API/Identity.API.csproj index 8d761b9ed..94e5b0bb3 100644 --- a/src/Services/Identity/Identity.API/Identity.API.csproj +++ b/src/Services/Identity/Identity.API/Identity.API.csproj @@ -51,9 +51,6 @@ - - Always - PreserveNewest diff --git a/src/Services/Location/Locations.API/.dockerignore b/src/Services/Location/Locations.API/.dockerignore deleted file mode 100644 index d8f8175f6..000000000 --- a/src/Services/Location/Locations.API/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!obj/Docker/publish/* -!obj/Docker/empty/ diff --git a/src/Services/Location/Locations.API/Dockerfile b/src/Services/Location/Locations.API/Dockerfile index 5a5edb3e7..56bef128d 100644 --- a/src/Services/Location/Locations.API/Dockerfile +++ b/src/Services/Location/Locations.API/Dockerfile @@ -1,6 +1,25 @@ -FROM microsoft/aspnetcore:2.0 -ARG source +FROM microsoft/aspnetcore:2.0 AS base WORKDIR /app EXPOSE 80 -COPY ${source:-obj/Docker/publish} . + +FROM microsoft/aspnetcore-build:2.0 AS build +WORKDIR /src +COPY eShopOnContainers-ServicesAndWebApps.sln ./ +COPY src/Services/Location/Locations.API/Locations.API.csproj src/Services/Location/Locations.API/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/Microsoft.AspNetCore.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Microsoft.Extensions.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/ +COPY src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj src/BuildingBlocks/EventBus/EventBusRabbitMQ/ +COPY src/BuildingBlocks/EventBus/EventBus/EventBus.csproj src/BuildingBlocks/EventBus/EventBus/ +COPY src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj src/BuildingBlocks/EventBus/EventBusServiceBus/ +RUN dotnet restore +COPY . . +WORKDIR /src/src/Services/Location/Locations.API +RUN dotnet build -c Release -o /app + +FROM build AS publish +RUN dotnet publish -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . ENTRYPOINT ["dotnet", "Locations.API.dll"] diff --git a/src/Services/Marketing/Marketing.API/.dockerignore b/src/Services/Marketing/Marketing.API/.dockerignore deleted file mode 100644 index d8f8175f6..000000000 --- a/src/Services/Marketing/Marketing.API/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!obj/Docker/publish/* -!obj/Docker/empty/ diff --git a/src/Services/Marketing/Marketing.API/Dockerfile b/src/Services/Marketing/Marketing.API/Dockerfile index bae6435ed..9c5ba08e2 100644 --- a/src/Services/Marketing/Marketing.API/Dockerfile +++ b/src/Services/Marketing/Marketing.API/Dockerfile @@ -1,6 +1,27 @@ -FROM microsoft/aspnetcore:2.0 -ARG source +FROM microsoft/aspnetcore:2.0 AS base WORKDIR /app EXPOSE 80 -COPY ${source:-obj/Docker/publish} . + +FROM microsoft/aspnetcore-build:2.0 AS build +WORKDIR /src +COPY eShopOnContainers-ServicesAndWebApps.sln ./ +COPY src/Services/Marketing/Marketing.API/Marketing.API.csproj src/Services/Marketing/Marketing.API/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/Microsoft.AspNetCore.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Microsoft.Extensions.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/ +COPY src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj src/BuildingBlocks/EventBus/EventBusRabbitMQ/ +COPY src/BuildingBlocks/EventBus/EventBus/EventBus.csproj src/BuildingBlocks/EventBus/EventBus/ +COPY src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj src/BuildingBlocks/EventBus/EventBusServiceBus/ +COPY src/BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj src/BuildingBlocks/WebHostCustomization/WebHost.Customization/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.AzureStorage/Microsoft.Extensions.HealthChecks.AzureStorage.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.AzureStorage/ +RUN dotnet restore +COPY . . +WORKDIR /src/src/Services/Marketing/Marketing.API +RUN dotnet build -c Release -o /app + +FROM build AS publish +RUN dotnet publish -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . ENTRYPOINT ["dotnet", "Marketing.API.dll"] diff --git a/src/Services/Marketing/Marketing.API/Marketing.API.csproj b/src/Services/Marketing/Marketing.API/Marketing.API.csproj index 373bda483..6e61604c7 100644 --- a/src/Services/Marketing/Marketing.API/Marketing.API.csproj +++ b/src/Services/Marketing/Marketing.API/Marketing.API.csproj @@ -45,9 +45,6 @@ - - Always - PreserveNewest diff --git a/src/Services/Ordering/Ordering.API/.dockerignore b/src/Services/Ordering/Ordering.API/.dockerignore deleted file mode 100644 index d8f8175f6..000000000 --- a/src/Services/Ordering/Ordering.API/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!obj/Docker/publish/* -!obj/Docker/empty/ diff --git a/src/Services/Ordering/Ordering.API/Dockerfile b/src/Services/Ordering/Ordering.API/Dockerfile index c7386bb43..601e0836b 100644 --- a/src/Services/Ordering/Ordering.API/Dockerfile +++ b/src/Services/Ordering/Ordering.API/Dockerfile @@ -1,6 +1,30 @@ -FROM microsoft/aspnetcore:2.0 -ARG source +FROM microsoft/aspnetcore:2.0 AS base WORKDIR /app EXPOSE 80 -COPY ${source:-obj/Docker/publish} . + +FROM microsoft/aspnetcore-build:2.0 AS build +WORKDIR /src +COPY eShopOnContainers-ServicesAndWebApps.sln ./ +COPY src/Services/Ordering/Ordering.API/Ordering.API.csproj src/Services/Ordering/Ordering.API/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/Microsoft.AspNetCore.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Microsoft.Extensions.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/ +COPY src/BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj src/BuildingBlocks/EventBus/IntegrationEventLogEF/ +COPY src/BuildingBlocks/EventBus/EventBus/EventBus.csproj src/BuildingBlocks/EventBus/EventBus/ +COPY src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj src/BuildingBlocks/EventBus/EventBusRabbitMQ/ +COPY src/Services/Ordering/Ordering.Domain/Ordering.Domain.csproj src/Services/Ordering/Ordering.Domain/ +COPY src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj src/BuildingBlocks/EventBus/EventBusServiceBus/ +COPY src/BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj src/BuildingBlocks/WebHostCustomization/WebHost.Customization/ +COPY src/Services/Ordering/Ordering.Infrastructure/Ordering.Infrastructure.csproj src/Services/Ordering/Ordering.Infrastructure/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.SqlServer/Microsoft.Extensions.HealthChecks.SqlServer.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.SqlServer/ +RUN dotnet restore +COPY . . +WORKDIR /src/src/Services/Ordering/Ordering.API +RUN dotnet build -c Release -o /app + +FROM build AS publish +RUN dotnet publish -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . ENTRYPOINT ["dotnet", "Ordering.API.dll"] diff --git a/src/Services/Ordering/Ordering.API/Ordering.API.csproj b/src/Services/Ordering/Ordering.API/Ordering.API.csproj index 9dee34091..16eb6e57f 100644 --- a/src/Services/Ordering/Ordering.API/Ordering.API.csproj +++ b/src/Services/Ordering/Ordering.API/Ordering.API.csproj @@ -11,9 +11,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest @@ -54,9 +51,6 @@ - - Always - PreserveNewest diff --git a/src/Services/Payment/Payment.API/.dockerignore b/src/Services/Payment/Payment.API/.dockerignore deleted file mode 100644 index d8f8175f6..000000000 --- a/src/Services/Payment/Payment.API/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!obj/Docker/publish/* -!obj/Docker/empty/ diff --git a/src/Services/Payment/Payment.API/Dockerfile b/src/Services/Payment/Payment.API/Dockerfile index 9f7491a16..eacf572d6 100644 --- a/src/Services/Payment/Payment.API/Dockerfile +++ b/src/Services/Payment/Payment.API/Dockerfile @@ -1,6 +1,27 @@ -FROM microsoft/aspnetcore:2.0 -ARG source +FROM microsoft/aspnetcore:2.0 AS base WORKDIR /app EXPOSE 80 -COPY ${source:-obj/Docker/publish} . + +FROM microsoft/aspnetcore-build:2.0 AS build +WORKDIR /src +COPY eShopOnContainers-ServicesAndWebApps.sln ./ +COPY src/Services/Payment/Payment.API/Payment.API.csproj src/Services/Payment/Payment.API/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/Microsoft.AspNetCore.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Microsoft.Extensions.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/ +COPY src/BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj src/BuildingBlocks/EventBus/IntegrationEventLogEF/ +COPY src/BuildingBlocks/EventBus/EventBus/EventBus.csproj src/BuildingBlocks/EventBus/EventBus/ +COPY src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj src/BuildingBlocks/EventBus/EventBusRabbitMQ/ +COPY src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj src/BuildingBlocks/EventBus/EventBusServiceBus/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.SqlServer/Microsoft.Extensions.HealthChecks.SqlServer.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.SqlServer/ +RUN dotnet restore +COPY . . +WORKDIR /src/src/Services/Payment/Payment.API +RUN dotnet build -c Release -o /app + +FROM build AS publish +RUN dotnet publish -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . ENTRYPOINT ["dotnet", "Payment.API.dll"] diff --git a/src/Web/Catalog.WebForms/Catalog.WebForms/Catalog.WebForms.csproj b/src/Web/Catalog.WebForms/Catalog.WebForms/Catalog.WebForms.csproj index 391983c31..aa829a4c8 100644 --- a/src/Web/Catalog.WebForms/Catalog.WebForms/Catalog.WebForms.csproj +++ b/src/Web/Catalog.WebForms/Catalog.WebForms/Catalog.WebForms.csproj @@ -150,9 +150,6 @@ PreserveNewest - - Dockerfile - diff --git a/src/Web/WebMVC/.dockerignore b/src/Web/WebMVC/.dockerignore deleted file mode 100644 index d8f8175f6..000000000 --- a/src/Web/WebMVC/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!obj/Docker/publish/* -!obj/Docker/empty/ diff --git a/src/Web/WebMVC/Dockerfile b/src/Web/WebMVC/Dockerfile index 729620bb9..0b2ab744f 100644 --- a/src/Web/WebMVC/Dockerfile +++ b/src/Web/WebMVC/Dockerfile @@ -1,6 +1,26 @@ -FROM microsoft/aspnetcore:2.0 -ARG source +FROM microsoft/aspnetcore:2.0 AS base WORKDIR /app EXPOSE 80 -COPY ${source:-obj/Docker/publish} . + +FROM microsoft/aspnetcore-build:2.0 AS build +WORKDIR /src +COPY eShopOnContainers-ServicesAndWebApps.sln ./ +COPY src/Web/WebMVC/WebMVC.csproj src/Web/WebMVC/ +COPY src/BuildingBlocks/DataProtection/DataProtection/DataProtection.csproj src/BuildingBlocks/DataProtection/DataProtection/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/Microsoft.AspNetCore.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Microsoft.Extensions.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/ +COPY src/BuildingBlocks/Resilience/Resilience.Http/Resilience.Http.csproj src/BuildingBlocks/Resilience/Resilience.Http/ +RUN dotnet restore +COPY . . +WORKDIR /src/src/Web/WebMVC +RUN dotnet build -c Release -o /app + +FROM build AS publish +RUN bower install --allow-root +RUN dotnet bundle +RUN dotnet publish -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . ENTRYPOINT ["dotnet", "WebMVC.dll"] diff --git a/src/Web/WebMVC/WebMVC.csproj b/src/Web/WebMVC/WebMVC.csproj index 47603f10f..479b21f27 100644 --- a/src/Web/WebMVC/WebMVC.csproj +++ b/src/Web/WebMVC/WebMVC.csproj @@ -27,10 +27,10 @@ - - + @@ -45,12 +45,6 @@ - - - Always - - - diff --git a/src/Web/WebMonolithic/eShopWeb/.dockerignore b/src/Web/WebMonolithic/eShopWeb/.dockerignore deleted file mode 100644 index d8f8175f6..000000000 --- a/src/Web/WebMonolithic/eShopWeb/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!obj/Docker/publish/* -!obj/Docker/empty/ diff --git a/src/Web/WebSPA/.dockerignore b/src/Web/WebSPA/.dockerignore deleted file mode 100644 index d8f8175f6..000000000 --- a/src/Web/WebSPA/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!obj/Docker/publish/* -!obj/Docker/empty/ diff --git a/src/Web/WebSPA/Dockerfile b/src/Web/WebSPA/Dockerfile index f08724dd8..7142d5f4f 100644 --- a/src/Web/WebSPA/Dockerfile +++ b/src/Web/WebSPA/Dockerfile @@ -1,6 +1,26 @@ -FROM microsoft/aspnetcore:2.0 -ARG source +FROM microsoft/aspnetcore:2.0 AS base WORKDIR /app EXPOSE 80 -COPY ${source:-obj/Docker/publish} . + +FROM microsoft/aspnetcore-build:2.0 AS build +WORKDIR /src +COPY eShopOnContainers-ServicesAndWebApps.sln ./ +COPY src/Web/WebSPA/WebSPA.csproj src/Web/WebSPA/ +COPY src/BuildingBlocks/DataProtection/DataProtection/DataProtection.csproj src/BuildingBlocks/DataProtection/DataProtection/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/Microsoft.AspNetCore.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Microsoft.Extensions.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/ +RUN dotnet restore +COPY . . +WORKDIR /src/src/Web/WebSPA +RUN dotnet build -c Release -o /app + +FROM build AS publish +RUN npm rebuild node-sass +RUN npm install +RUN npm run build:prod +RUN dotnet publish -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . ENTRYPOINT ["dotnet", "WebSPA.dll"] diff --git a/src/Web/WebSPA/WebSPA.csproj b/src/Web/WebSPA/WebSPA.csproj index 308dc5324..fa5a8a8f4 100644 --- a/src/Web/WebSPA/WebSPA.csproj +++ b/src/Web/WebSPA/WebSPA.csproj @@ -36,14 +36,14 @@ - + @@ -66,12 +66,6 @@ - - - Always - - - diff --git a/src/Web/WebSPA/package-lock.json b/src/Web/WebSPA/package-lock.json index bc4b391e9..313a88257 100644 --- a/src/Web/WebSPA/package-lock.json +++ b/src/Web/WebSPA/package-lock.json @@ -9243,15 +9243,6 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -9263,6 +9254,15 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", @@ -10085,12 +10085,6 @@ "integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=", "dev": true }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", @@ -10118,6 +10112,12 @@ } } }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, "stringstream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", diff --git a/src/Web/WebStatus/.dockerignore b/src/Web/WebStatus/.dockerignore deleted file mode 100644 index d8f8175f6..000000000 --- a/src/Web/WebStatus/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!obj/Docker/publish/* -!obj/Docker/empty/ diff --git a/src/Web/WebStatus/Dockerfile b/src/Web/WebStatus/Dockerfile index 8d9b70884..f69f0853d 100644 --- a/src/Web/WebStatus/Dockerfile +++ b/src/Web/WebStatus/Dockerfile @@ -1,6 +1,22 @@ -FROM microsoft/aspnetcore:2.0 -ARG source +FROM microsoft/aspnetcore:2.0 AS base WORKDIR /app EXPOSE 80 -COPY ${source:-obj/Docker/publish} . + +FROM microsoft/aspnetcore-build:2.0 AS build +WORKDIR /src +COPY eShopOnContainers-ServicesAndWebApps.sln ./ +COPY src/Web/WebStatus/WebStatus.csproj src/Web/WebStatus/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/Microsoft.AspNetCore.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/ +COPY src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Microsoft.Extensions.HealthChecks.csproj src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/ +RUN dotnet restore +COPY . . +WORKDIR /src/src/Web/WebStatus +RUN dotnet build -c Release -o /app + +FROM build AS publish +RUN dotnet publish -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . ENTRYPOINT ["dotnet", "WebStatus.dll"] From dbd7636e874d1ef635afe1cbba27f8ef66e17f1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Tom=C3=A1s?= Date: Mon, 11 Dec 2017 11:59:30 +0100 Subject: [PATCH 4/6] Removed comment from k8s deploy script --- k8s/deploy.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/deploy.ps1 b/k8s/deploy.ps1 index 96afd2cfb..bcb2d7393 100644 --- a/k8s/deploy.ps1 +++ b/k8s/deploy.ps1 @@ -104,7 +104,7 @@ ExecKube -cmd 'delete configmap config-files' ExecKube -cmd 'delete configmap urls' ExecKube -cmd 'delete configmap externalcfg' -# start sql, rabbitmq, frontend deploymentsExecKube -cmd 'delete configmap config-files' +# start sql, rabbitmq, frontend deployments ExecKube -cmd 'create configmap config-files --from-file=nginx-conf=nginx.conf' ExecKube -cmd 'label configmap config-files app=eshop' From fd3afa41db9f3b357396081f85c9af6a2a937db7 Mon Sep 17 00:00:00 2001 From: Sychev Igor Date: Mon, 11 Dec 2017 17:55:41 +0300 Subject: [PATCH 5/6] aks instead of acs --- k8s/README.CICD.k8s.md | 8 ++++++-- k8s/README.k8s.md | 6 +++++- k8s/gen-k8s-env-aks.ps1 | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 k8s/gen-k8s-env-aks.ps1 diff --git a/k8s/README.CICD.k8s.md b/k8s/README.CICD.k8s.md index 99611043d..3a83accc9 100644 --- a/k8s/README.CICD.k8s.md +++ b/k8s/README.CICD.k8s.md @@ -4,11 +4,15 @@ For k8s CI/CD pipeline delivery a series of tasks must be created in VSTS to dep ## Prerequisites * A Kubernetes cluster. Follow Azure Container Service's [walkthrough](https://docs.microsoft.com/en-us/azure/container-service/container-service-kubernetes-walkthrough) to create one. * A private Docker registry. Follow Azure Container Registry's [guide](https://docs.microsoft.com/en-us/azure/container-registry/container-registry-get-started-portal) to create one. -* Optionally, previous steps can be skipped if you run gen-k8s-env.ps1 script to automatically create the azure environment needed for kubernetes deployment. Azure cli 2.0 must be previously installed [installation guide](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli). For example: +* Optionally, previous steps can be skipped if you run gen-k8s-env.ps1 (or gen-k8s-env-aks.ps1 if you would like to use AKS instead of ACS) script to automatically create the azure environment needed for kubernetes deployment. Azure cli 2.0 must be previously installed [installation guide](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli). For example: >``` >./gen-k8s-env -resourceGroupName k8sGroup -location westeurope -registryName k8sregistry -orchestratorName k8s-cluster -dnsName k8s-dns >``` +or using AKS instead of ACS +>``` +>./gen-k8s-env-aks -resourceGroupName k8sGroup -location westeurope -registryName k8sregistry -dnsName k8s-dns -serviceName k8s-cluster -createAcr true -nodeCount 3 -nodeVMSize Standard_D2_v2 +>``` * An `Azure Blob storage`. It is needed for storing the kubernetes config file used by the hosted agent to access to Kubernetes cluster. Example: @@ -23,7 +27,7 @@ For k8s CI/CD pipeline delivery a series of tasks must be created in VSTS to dep 1. Create a `Download File` task to download the kubernetes binary `kubectl` to the hosted agent. For example: >``` ->https://storage.googleapis.com/kubernetes-release/release/v0.0.1.7.0-alpha.0/bin/windows/386/kubectl.exe +>https://storage.googleapis.com/kubernetes-release/release/v1.8.5/bin/windows/386/kubectl.exe >``` diff --git a/k8s/README.k8s.md b/k8s/README.k8s.md index ebbca0c33..85bcdec6c 100644 --- a/k8s/README.k8s.md +++ b/k8s/README.k8s.md @@ -4,13 +4,17 @@ The k8s directory contains Kubernetes configuration for the eShopOnContainers ap ## Prerequisites * A Kubernetes cluster. Follow Azure Container Service's [walkthrough](https://docs.microsoft.com/en-us/azure/container-service/container-service-kubernetes-walkthrough) to create one. * A private Docker registry. Follow Azure Container Registry's [guide](https://docs.microsoft.com/en-us/azure/container-registry/container-registry-get-started-portal) to create one. -* Optionally, previous steps can be skipped if you run gen-k8s-env.ps1 script to automatically create the azure environment needed for kubernetes deployment. Azure cli 2.0 must be previously installed [installation guide](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli). For example: +* Optionally, previous steps can be skipped if you run gen-k8s-env.ps1 (or gen-k8s-env-aks.ps1 if you would like to use AKS instead of ACS) script to automatically create the azure environment needed for kubernetes deployment. Azure cli 2.0 must be previously installed [installation guide](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli). For example: **Important**: Note the parameter "-createAcr true". If you are creating the K8s cluster but you want to re-use and existing ACR, say "-createAcr false". >``` >./gen-k8s-env -resourceGroupName k8sGroup -location westeurope -registryName k8sregistry -createAcr true -orchestratorName k8s-cluster -dnsName k8s-dns >``` +or using AKS instead of ACS +>``` +>./gen-k8s-env-aks -resourceGroupName k8sGroup -location westeurope -registryName k8sregistry -dnsName k8s-dns -serviceName k8s-cluster -createAcr true -nodeCount 3 -nodeVMSize Standard_D2_v2 +>``` * A Docker development environment with `docker` and `docker-compose`. * Visit [docker.com](https://docker.com) to download the tools and set up the environment. Docker's [installation guide](https://docs.docker.com/engine/getstarted/step_one/#step-3-verify-your-installation) covers verifying your Docker installation. diff --git a/k8s/gen-k8s-env-aks.ps1 b/k8s/gen-k8s-env-aks.ps1 new file mode 100644 index 000000000..6b8449565 --- /dev/null +++ b/k8s/gen-k8s-env-aks.ps1 @@ -0,0 +1,32 @@ +Param( + [parameter(Mandatory=$true)][string]$resourceGroupName, + [parameter(Mandatory=$true)][string]$location, + [parameter(Mandatory=$false)][string]$registryName, + [parameter(Mandatory=$true)][string]$serviceName, + [parameter(Mandatory=$true)][string]$dnsName, + [parameter(Mandatory=$true)][string]$createAcr=$true, + [parameter(Mandatory=$false)][int]$nodeCount=2, + [parameter(Mandatory=$false)][string]$nodeVMSize="Standard_D2_v2" +) + +# Create resource group +Write-Host "Creating resource group..." -ForegroundColor Yellow +az group create --name=$resourceGroupName --location=$location + +if ($createAcr -eq $true) { + # Create Azure Container Registry + Write-Host "Creating Azure Container Registry..." -ForegroundColor Yellow + az acr create -n $registryName -g $resourceGroupName -l $location --admin-enabled true --sku Basic +} + +# Create kubernetes orchestrator +Write-Host "Creating kubernetes orchestrator..." -ForegroundColor Yellow +az aks create --resource-group=$resourceGroupName --name=$serviceName --dns-name-prefix=$dnsName --generate-ssh-keys --node-count=$nodeCount --node-vm-size=$nodeVMSize + +# Retrieve kubernetes cluster configuration and save it under ~/.kube/config +az aks get-credentials --resource-group=$resourceGroupName --name=$serviceName + +if ($createAcr -eq $true) { + # Show ACR credentials + az acr credential show -n $registryName +} \ No newline at end of file From e9a89ae553a8c58cf78b4a53331e52fa6d01a1f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Tom=C3=A1s?= Date: Mon, 11 Dec 2017 16:25:00 +0100 Subject: [PATCH 6/6] Fixed issue #403 Fixed issue #419 --- docker-compose-external.override.yml | 9 ++++-- docker-compose-external.yml | 3 ++ .../Commands/CancelOrderCommandHandler.cs | 5 +++ .../Commands/ShipOrderCommandHandler.cs | 5 +++ .../Services/Basket/appsettings.json | 3 +- .../Services/Catalog/CatalogScenariosBase.cs | 31 ++++++++++++++----- .../Services/Catalog/appsettings.json | 3 +- .../Services/Location/appsettings.json | 3 +- .../Marketing/MarketingScenariosBase.cs | 20 ++++++++++-- .../Services/Marketing/appsettings.json | 3 +- .../Ordering/OrderingScenariosBase.cs | 26 +++++++++++++--- .../Services/Ordering/settings.json | 3 +- .../Services/Basket/appsettings.json | 3 +- .../Services/Catalog/CatalogScenarioBase.cs | 22 ++++++++++++- .../Services/Catalog/appsettings.json | 3 +- .../Services/Locations/appsettings.json | 3 +- .../Marketing/MarketingScenariosBase.cs | 18 ++++++++++- .../Services/Marketing/appsettings.json | 3 +- .../Services/Ordering/OrderingScenarioBase.cs | 23 +++++++++++++- .../Services/Ordering/OrderingScenarios.cs | 8 ++--- .../Services/Ordering/settings.json | 3 +- 21 files changed, 166 insertions(+), 34 deletions(-) diff --git a/docker-compose-external.override.yml b/docker-compose-external.override.yml index 60764ca54..e20d2d949 100644 --- a/docker-compose-external.override.yml +++ b/docker-compose-external.override.yml @@ -1,9 +1,14 @@ -version: '2' +version: '3' services: sql.data: environment: - MSSQL_SA_PASSWORD=Pass@word - ACCEPT_EULA=Y + - MSSQL_PID=Developer ports: - - "5433:1433" \ No newline at end of file + - "5433:1433" + + nosql.data: + ports: + - "27017:27017" \ No newline at end of file diff --git a/docker-compose-external.yml b/docker-compose-external.yml index 8d8e0e760..9570696d2 100644 --- a/docker-compose-external.yml +++ b/docker-compose-external.yml @@ -13,3 +13,6 @@ services: image: rabbitmq ports: - "5672:5672" + + nosql.data: + image: mongo diff --git a/src/Services/Ordering/Ordering.API/Application/Commands/CancelOrderCommandHandler.cs b/src/Services/Ordering/Ordering.API/Application/Commands/CancelOrderCommandHandler.cs index a6d482c26..a16acb0f3 100644 --- a/src/Services/Ordering/Ordering.API/Application/Commands/CancelOrderCommandHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/Commands/CancelOrderCommandHandler.cs @@ -28,6 +28,11 @@ namespace Ordering.API.Application.Commands public async Task Handle(CancelOrderCommand command) { var orderToUpdate = await _orderRepository.GetAsync(command.OrderNumber); + if(orderToUpdate == null) + { + return false; + } + orderToUpdate.SetCancelledStatus(); return await _orderRepository.UnitOfWork.SaveEntitiesAsync(); } diff --git a/src/Services/Ordering/Ordering.API/Application/Commands/ShipOrderCommandHandler.cs b/src/Services/Ordering/Ordering.API/Application/Commands/ShipOrderCommandHandler.cs index d1fa6a71b..7755dae32 100644 --- a/src/Services/Ordering/Ordering.API/Application/Commands/ShipOrderCommandHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/Commands/ShipOrderCommandHandler.cs @@ -25,6 +25,11 @@ namespace Ordering.API.Application.Commands public async Task Handle(ShipOrderCommand command) { var orderToUpdate = await _orderRepository.GetAsync(command.OrderNumber); + if(orderToUpdate == null) + { + return false; + } + orderToUpdate.SetShippedStatus(); return await _orderRepository.UnitOfWork.SaveEntitiesAsync(); } diff --git a/test/Services/FunctionalTests/Services/Basket/appsettings.json b/test/Services/FunctionalTests/Services/Basket/appsettings.json index 0d84f580e..f83d4de4b 100644 --- a/test/Services/FunctionalTests/Services/Basket/appsettings.json +++ b/test/Services/FunctionalTests/Services/Basket/appsettings.json @@ -10,7 +10,8 @@ "IdentityUrl": "http://localhost:5105", "ConnectionString": "127.0.0.1", "isTest": "true", - "EventBusConnection": "localhost" + "EventBusConnection": "localhost", + "SubscriptionClientName": "Basket" } diff --git a/test/Services/FunctionalTests/Services/Catalog/CatalogScenariosBase.cs b/test/Services/FunctionalTests/Services/Catalog/CatalogScenariosBase.cs index f5714afac..2d5daff6d 100644 --- a/test/Services/FunctionalTests/Services/Catalog/CatalogScenariosBase.cs +++ b/test/Services/FunctionalTests/Services/Catalog/CatalogScenariosBase.cs @@ -1,13 +1,13 @@ -using FunctionalTests.Middleware; -using Microsoft.AspNetCore; +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; +using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF; using Microsoft.eShopOnContainers.Services.Catalog.API; -using Microsoft.Extensions.Configuration; -using System; -using System.Collections.Generic; +using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using System.IO; -using System.Text; namespace FunctionalTests.Services.Catalog { @@ -18,8 +18,23 @@ namespace FunctionalTests.Services.Catalog var webHostBuilder = WebHost.CreateDefaultBuilder(); webHostBuilder.UseContentRoot(Directory.GetCurrentDirectory() + "\\Services\\Catalog"); webHostBuilder.UseStartup(); - - return new TestServer(webHostBuilder); + + var testServer = new TestServer(webHostBuilder); + + testServer.Host + .MigrateDbContext((context, services) => + { + var env = services.GetService(); + var settings = services.GetService>(); + var logger = services.GetService>(); + + new CatalogContextSeed() + .SeedAsync(context, env, settings, logger) + .Wait(); + }) + .MigrateDbContext((_, __) => { }); + + return testServer; } public static class Get diff --git a/test/Services/FunctionalTests/Services/Catalog/appsettings.json b/test/Services/FunctionalTests/Services/Catalog/appsettings.json index c814821c0..0cd61e36b 100644 --- a/test/Services/FunctionalTests/Services/Catalog/appsettings.json +++ b/test/Services/FunctionalTests/Services/Catalog/appsettings.json @@ -4,5 +4,6 @@ "IdentityUrl": "http://localhost:5105", "isTest": "true", "EventBusConnection": "localhost", - "PicBaseUrl": "http://localhost:5101/api/v1/catalog/items/[0]/pic/" + "PicBaseUrl": "http://localhost:5101/api/v1/catalog/items/[0]/pic/", + "SubscriptionClientName": "Catalog" } diff --git a/test/Services/FunctionalTests/Services/Location/appsettings.json b/test/Services/FunctionalTests/Services/Location/appsettings.json index 9769fb65a..977401adc 100644 --- a/test/Services/FunctionalTests/Services/Location/appsettings.json +++ b/test/Services/FunctionalTests/Services/Location/appsettings.json @@ -4,5 +4,6 @@ "ExternalCatalogBaseUrl": "http://localhost:5101", "IdentityUrl": "http://localhost:5105", "isTest": "true", - "EventBusConnection": "localhost" + "EventBusConnection": "localhost", + "SubscriptionClientName": "Location" } diff --git a/test/Services/FunctionalTests/Services/Marketing/MarketingScenariosBase.cs b/test/Services/FunctionalTests/Services/Marketing/MarketingScenariosBase.cs index 2920485f7..fe4f6c0cd 100644 --- a/test/Services/FunctionalTests/Services/Marketing/MarketingScenariosBase.cs +++ b/test/Services/FunctionalTests/Services/Marketing/MarketingScenariosBase.cs @@ -3,7 +3,9 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; - using Microsoft.Extensions.Configuration; + using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure; + using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.Logging; using System.IO; public class MarketingScenariosBase @@ -14,9 +16,21 @@ { var webHostBuilder = WebHost.CreateDefaultBuilder(); webHostBuilder.UseContentRoot(Directory.GetCurrentDirectory() + "\\Services\\Marketing"); - webHostBuilder.UseStartup(); + webHostBuilder.UseStartup(); - return new TestServer(webHostBuilder); + var testServer = new TestServer(webHostBuilder); + + testServer.Host + .MigrateDbContext((context, services) => + { + var logger = services.GetService>(); + + new MarketingContextSeed() + .SeedAsync(context, logger) + .Wait(); + }); + + return testServer; } } } \ No newline at end of file diff --git a/test/Services/FunctionalTests/Services/Marketing/appsettings.json b/test/Services/FunctionalTests/Services/Marketing/appsettings.json index eae81073f..2aa46abe6 100644 --- a/test/Services/FunctionalTests/Services/Marketing/appsettings.json +++ b/test/Services/FunctionalTests/Services/Marketing/appsettings.json @@ -7,5 +7,6 @@ "EventBusConnection": "localhost", "AzureServiceBusEnabled": false, "SubscriptionClientName": "Marketing", - "PicBaseUrl": "http://localhost:5110/api/v1/campaigns/[0]/pic/" + "PicBaseUrl": "http://localhost:5110/api/v1/campaigns/[0]/pic/", + "SubscriptionClientName": "Marketing" } diff --git a/test/Services/FunctionalTests/Services/Ordering/OrderingScenariosBase.cs b/test/Services/FunctionalTests/Services/Ordering/OrderingScenariosBase.cs index d2a2dcfd9..b41f66fb9 100644 --- a/test/Services/FunctionalTests/Services/Ordering/OrderingScenariosBase.cs +++ b/test/Services/FunctionalTests/Services/Ordering/OrderingScenariosBase.cs @@ -1,11 +1,15 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; +using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF; +using Microsoft.eShopOnContainers.Services.Ordering.API; +using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure; +using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure; using Microsoft.Extensions.Configuration; -using System; -using System.Collections.Generic; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using System.IO; -using System.Text; namespace FunctionalTests.Services.Ordering { @@ -21,8 +25,22 @@ namespace FunctionalTests.Services.Ordering config.AddJsonFile("settings.json"); }); + var testServer = new TestServer(webHostBuilder); - return new TestServer(webHostBuilder); + testServer.Host + .MigrateDbContext((context, services) => + { + var env = services.GetService(); + var settings = services.GetService>(); + var logger = services.GetService>(); + + new OrderingContextSeed() + .SeedAsync(context, env, settings, logger) + .Wait(); + }) + .MigrateDbContext((_, __) => { }); + + return testServer; } public static class Get diff --git a/test/Services/FunctionalTests/Services/Ordering/settings.json b/test/Services/FunctionalTests/Services/Ordering/settings.json index 072612e0f..70f1af3c0 100644 --- a/test/Services/FunctionalTests/Services/Ordering/settings.json +++ b/test/Services/FunctionalTests/Services/Ordering/settings.json @@ -5,5 +5,6 @@ "isTest": "true", "EventBusConnection": "localhost", "CheckUpdateTime": "30000", - "GracePeriodTime": "1" + "GracePeriodTime": "1", + "SubscriptionClientName": "Ordering" } diff --git a/test/Services/IntegrationTests/Services/Basket/appsettings.json b/test/Services/IntegrationTests/Services/Basket/appsettings.json index 0d84f580e..f83d4de4b 100644 --- a/test/Services/IntegrationTests/Services/Basket/appsettings.json +++ b/test/Services/IntegrationTests/Services/Basket/appsettings.json @@ -10,7 +10,8 @@ "IdentityUrl": "http://localhost:5105", "ConnectionString": "127.0.0.1", "isTest": "true", - "EventBusConnection": "localhost" + "EventBusConnection": "localhost", + "SubscriptionClientName": "Basket" } diff --git a/test/Services/IntegrationTests/Services/Catalog/CatalogScenarioBase.cs b/test/Services/IntegrationTests/Services/Catalog/CatalogScenarioBase.cs index fe1030a73..57d8c6ef1 100644 --- a/test/Services/IntegrationTests/Services/Catalog/CatalogScenarioBase.cs +++ b/test/Services/IntegrationTests/Services/Catalog/CatalogScenarioBase.cs @@ -3,7 +3,12 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; + using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF; using Microsoft.eShopOnContainers.Services.Catalog.API; + using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure; + using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Options; using System.IO; public class CatalogScenarioBase @@ -14,7 +19,22 @@ webHostBuilder.UseContentRoot(Directory.GetCurrentDirectory() + "\\Services\\Catalog"); webHostBuilder.UseStartup(); - return new TestServer(webHostBuilder); + var testServer = new TestServer(webHostBuilder); + + testServer.Host + .MigrateDbContext((context, services) => + { + var env = services.GetService(); + var settings = services.GetService>(); + var logger = services.GetService>(); + + new CatalogContextSeed() + .SeedAsync(context, env, settings, logger) + .Wait(); + }) + .MigrateDbContext((_, __) => { }); + + return testServer; } public static class Get diff --git a/test/Services/IntegrationTests/Services/Catalog/appsettings.json b/test/Services/IntegrationTests/Services/Catalog/appsettings.json index c814821c0..0cd61e36b 100644 --- a/test/Services/IntegrationTests/Services/Catalog/appsettings.json +++ b/test/Services/IntegrationTests/Services/Catalog/appsettings.json @@ -4,5 +4,6 @@ "IdentityUrl": "http://localhost:5105", "isTest": "true", "EventBusConnection": "localhost", - "PicBaseUrl": "http://localhost:5101/api/v1/catalog/items/[0]/pic/" + "PicBaseUrl": "http://localhost:5101/api/v1/catalog/items/[0]/pic/", + "SubscriptionClientName": "Catalog" } diff --git a/test/Services/IntegrationTests/Services/Locations/appsettings.json b/test/Services/IntegrationTests/Services/Locations/appsettings.json index 9769fb65a..ee763ba96 100644 --- a/test/Services/IntegrationTests/Services/Locations/appsettings.json +++ b/test/Services/IntegrationTests/Services/Locations/appsettings.json @@ -4,5 +4,6 @@ "ExternalCatalogBaseUrl": "http://localhost:5101", "IdentityUrl": "http://localhost:5105", "isTest": "true", - "EventBusConnection": "localhost" + "EventBusConnection": "localhost", + "SubscriptionClientName": "Locations" } diff --git a/test/Services/IntegrationTests/Services/Marketing/MarketingScenariosBase.cs b/test/Services/IntegrationTests/Services/Marketing/MarketingScenariosBase.cs index 965d8772c..7d0bf784e 100644 --- a/test/Services/IntegrationTests/Services/Marketing/MarketingScenariosBase.cs +++ b/test/Services/IntegrationTests/Services/Marketing/MarketingScenariosBase.cs @@ -3,6 +3,9 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; + using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure; + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.DependencyInjection; using System.IO; public class MarketingScenarioBase @@ -15,7 +18,20 @@ webHostBuilder.UseContentRoot(Directory.GetCurrentDirectory() + "\\Services\\Marketing"); webHostBuilder.UseStartup(); - return new TestServer(webHostBuilder); + var testServer = new TestServer(webHostBuilder); + + testServer.Host + .MigrateDbContext((context, services) => + { + var logger = services.GetService>(); + + new MarketingContextSeed() + .SeedAsync(context, logger) + .Wait(); + + }); + + return testServer; } } } \ No newline at end of file diff --git a/test/Services/IntegrationTests/Services/Marketing/appsettings.json b/test/Services/IntegrationTests/Services/Marketing/appsettings.json index 59ef38d0a..4a57bb0f5 100644 --- a/test/Services/IntegrationTests/Services/Marketing/appsettings.json +++ b/test/Services/IntegrationTests/Services/Marketing/appsettings.json @@ -5,5 +5,6 @@ "IdentityUrl": "http://localhost:5105", "isTest": "true", "EventBusConnection": "localhost", - "PicBaseUrl": "http://localhost:5110/api/v1/campaigns/[0]/pic/" + "PicBaseUrl": "http://localhost:5110/api/v1/campaigns/[0]/pic/", + "SubscriptionClientName": "Marketing" } diff --git a/test/Services/IntegrationTests/Services/Ordering/OrderingScenarioBase.cs b/test/Services/IntegrationTests/Services/Ordering/OrderingScenarioBase.cs index c59144e36..082ad4cd9 100644 --- a/test/Services/IntegrationTests/Services/Ordering/OrderingScenarioBase.cs +++ b/test/Services/IntegrationTests/Services/Ordering/OrderingScenarioBase.cs @@ -4,8 +4,14 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; using Microsoft.eShopOnContainers.Services.Ordering.API; + using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure; + using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure; + using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Configuration; + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Options; using System.IO; + using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF; public class OrderingScenarioBase { @@ -19,7 +25,22 @@ config.AddJsonFile("settings.json"); }); - return new TestServer(webHostBuilder); + var testServer = new TestServer(webHostBuilder); + + testServer.Host + .MigrateDbContext((context, services) => + { + var env = services.GetService(); + var settings = services.GetService>(); + var logger = services.GetService>(); + + new OrderingContextSeed() + .SeedAsync(context, env, settings, logger) + .Wait(); + }) + .MigrateDbContext((_, __) => { }); + + return testServer; } public static class Get diff --git a/test/Services/IntegrationTests/Services/Ordering/OrderingScenarios.cs b/test/Services/IntegrationTests/Services/Ordering/OrderingScenarios.cs index afcdf99c3..2d87e8395 100644 --- a/test/Services/IntegrationTests/Services/Ordering/OrderingScenarios.cs +++ b/test/Services/IntegrationTests/Services/Ordering/OrderingScenarios.cs @@ -25,7 +25,7 @@ } [Fact] - public async Task Cancel_order_no_order_created_response_500_status_code() + public async Task Cancel_order_no_order_created_bad_request_response() { using (var server = CreateServer()) { @@ -33,12 +33,12 @@ var response = await server.CreateIdempotentClient() .PutAsync(Put.CancelOrder, content); - Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode); + Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); } } [Fact] - public async Task Ship_order_no_order_created_response_500_status_code() + public async Task Ship_order_no_order_created_bad_request_response() { using (var server = CreateServer()) { @@ -46,7 +46,7 @@ var response = await server.CreateIdempotentClient() .PutAsync(Put.ShipOrder, content); - Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode); + Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); } } diff --git a/test/Services/IntegrationTests/Services/Ordering/settings.json b/test/Services/IntegrationTests/Services/Ordering/settings.json index 072612e0f..70f1af3c0 100644 --- a/test/Services/IntegrationTests/Services/Ordering/settings.json +++ b/test/Services/IntegrationTests/Services/Ordering/settings.json @@ -5,5 +5,6 @@ "isTest": "true", "EventBusConnection": "localhost", "CheckUpdateTime": "30000", - "GracePeriodTime": "1" + "GracePeriodTime": "1", + "SubscriptionClientName": "Ordering" }