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


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 AS build

COPY *.sln .
COPY Src Src

WORKDIR /app/Src/WebUI
RUN dotnet restore

RUN dotnet publish -c Release -o out

# 3 - Runtime
FROM AS runtime

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


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: