Add Dockerfile

You are going to add Docker support to Northwind solution, not CDK project.

Add Dockerfile to build your Northwind application using Docker container and also to run it from Docker container.

Add the following Dockerfile (file should be named Dockerfile without extension) to the root of the project (next to the Northwind.sln file).

# 1 - Build Angular App
FROM node:10 as node

WORKDIR /app

COPY Src/WebUI/ClientApp/package*.json ./

RUN npm install

COPY Src/WebUI/ClientApp/*.* ./
COPY Src/WebUI/ClientApp/src ./src

RUN npm run build

# 2 - Build ASP.NET Core app
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /app

COPY *.sln .
COPY Src Src

WORKDIR /app/Src/WebUI
RUN dotnet restore

RUN dotnet publish -c Release -o out

# 3 - Runtime
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS runtime
WORKDIR /app

COPY --from=node /app/dist ./ClientApp/dist/
COPY --from=build /app/Src/WebUI/out ./

ENV ASPNETCORE_ENVIRONMENT Development

ENTRYPOINT ["dotnet", "Northwind.WebUI.dll"]

This is multistage Dockerfile that does the following:

  1. Uses Node.js 10 image to build Angular application
  2. Uses .NET Core 3.1 SDK image to build ASP.NET Core application
  3. Uses .NET Core 3.1 runtime image to run our application

In order not to copy large node_modules folder into container, please add .dockerignore file with the following content next to the Dockerfile:

**/node_modules