From 48ad346b3c78bd234b17c76a21e5549091c87b9d Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Thu, 7 Jun 2018 15:50:32 -0400 Subject: [PATCH] Updating Dockerfiles Adding instructions and cleaning up. --- src/Web/Controllers/AccountController.cs | 3 +-- src/Web/Dockerfile | 32 +++++++++++++++--------- src/WebRazorPages/Dockerfile | 32 +++++++++++++++--------- 3 files changed, 41 insertions(+), 26 deletions(-) diff --git a/src/Web/Controllers/AccountController.cs b/src/Web/Controllers/AccountController.cs index 606f2b230..f3dfbf1d5 100644 --- a/src/Web/Controllers/AccountController.cs +++ b/src/Web/Controllers/AccountController.cs @@ -10,7 +10,6 @@ namespace Microsoft.eShopWeb.Web.Controllers { - [Route("[controller]/[action]")] [Authorize] public class AccountController : Controller @@ -40,7 +39,7 @@ public async Task SignIn(string returnUrl = null) await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); ViewData["ReturnUrl"] = returnUrl; - if (!String.IsNullOrEmpty(returnUrl) && + if (!String.IsNullOrEmpty(returnUrl) && returnUrl.IndexOf("checkout", StringComparison.OrdinalIgnoreCase) >= 0) { ViewData["ReturnUrl"] = "/Basket/Index"; diff --git a/src/Web/Dockerfile b/src/Web/Dockerfile index bb1a758c1..835b4016a 100644 --- a/src/Web/Dockerfile +++ b/src/Web/Dockerfile @@ -1,19 +1,27 @@ -FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base +# RUN BOTH CONTAINERS FROM ROOT (folder with .sln file): +# docker-compose build +# docker-compose up +# +# RUN JUST THIS CONTAINER FROM ROOT (folder with .sln file): +# docker build --pull -t web -f src/Web/Dockerfile . +# +# RUN COMMAND +# docker run --name eshopweb --rm -it -p 8000:5106 web +FROM microsoft/dotnet:2.1-sdk AS build WORKDIR /app -EXPOSE 80 -FROM microsoft/aspnetcore-build:2.1.300-preview1 AS build -RUN npm install -g bower@1.8.4 -WORKDIR /src +COPY *.sln . COPY . . -WORKDIR /src/src/Web -RUN dotnet restore -nowarn:msb3202,nu1503 -RUN dotnet build --no-restore -c Release -o /app +WORKDIR /app/src/Web +RUN dotnet restore -FROM build AS publish -RUN dotnet publish --no-restore -c Release -o /app +RUN dotnet publish -c Release -o out -FROM base AS final +FROM microsoft/dotnet:2.1-aspnetcore-runtime AS runtime WORKDIR /app -COPY --from=publish /app . +COPY --from=build /app/src/Web/out ./ + +# Optional: Set this here if not setting it from docker-compose.yml +# ENV ASPNETCORE_ENVIRONMENT Development + ENTRYPOINT ["dotnet", "Web.dll"] diff --git a/src/WebRazorPages/Dockerfile b/src/WebRazorPages/Dockerfile index 83d110bcf..ca49eb1ff 100644 --- a/src/WebRazorPages/Dockerfile +++ b/src/WebRazorPages/Dockerfile @@ -1,19 +1,27 @@ -FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base +# RUN BOTH CONTAINERS FROM ROOT (folder with .sln file): +# docker-compose build +# docker-compose up +# +# RUN JUST THIS CONTAINER FROM ROOT (folder with .sln file): +# docker build --pull -t webrazor -f src/WebRazorPages/Dockerfile . +# +# RUN COMMAND +# docker run --name eshopweb --rm -it -p 5107:5107 webrazor +FROM microsoft/dotnet:2.1-sdk AS build WORKDIR /app -EXPOSE 80 -FROM microsoft/aspnetcore-build:2.1.300-preview1 AS build -RUN npm install -g bower@1.8.4 -WORKDIR /src +COPY *.sln . COPY . . -WORKDIR /src/src/WebRazorPages -RUN dotnet restore -nowarn:msb3202,nu1503 -RUN dotnet build --no-restore -c Release -o /app +WORKDIR /app/src/WebRazorPages +RUN dotnet restore -FROM build AS publish -RUN dotnet publish --no-restore -c Release -o /app +RUN dotnet publish -c Release -o out -FROM base AS final +FROM microsoft/dotnet:2.1-aspnetcore-runtime AS runtime WORKDIR /app -COPY --from=publish /app . +COPY --from=build /app/src/WebRazorPages/out ./ + +# Optional: Set this here if not setting it from docker-compose.yml +# ENV ASPNETCORE_ENVIRONMENT Development + ENTRYPOINT ["dotnet", "Microsoft.eShopWeb.RazorPages.dll"]