Skip to content

Commit

Permalink
Updating Dockerfiles
Browse files Browse the repository at this point in the history
Adding instructions and cleaning up.
  • Loading branch information
ardalis committed Jun 7, 2018
1 parent 74bc28e commit 48ad346
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 26 deletions.
3 changes: 1 addition & 2 deletions src/Web/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace Microsoft.eShopWeb.Web.Controllers
{

[Route("[controller]/[action]")]
[Authorize]
public class AccountController : Controller
Expand Down Expand Up @@ -40,7 +39,7 @@ public async Task<IActionResult> 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";
Expand Down
32 changes: 20 additions & 12 deletions src/Web/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
32 changes: 20 additions & 12 deletions src/WebRazorPages/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 48ad346

Please sign in to comment.