This section is focused on the deployment step of the .NET worker template. We will proceed by running our service on a Docker Linux image. As we have already seen in Chapter 12, The Containerization of Services, we will use Docker to run the application in a container.
Let's start by configuring the Dockerfile in the project folder:
FROM mcr.microsoft.com/dotnet/core/runtime:3.0 AS base
WORKDIR /app
# Step 1 - Building the project
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build
WORKDIR /src
COPY ["HealthCheckWorker.csproj", "./"]
RUN dotnet restore "./HealthCheckWorker.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "HealthCheckWorker.csproj" -c Release -o /app/build
# Step 2 - Publish the project
FROM build AS publish
RUN dotnet publish "HealthCheckWorker.csproj" -c Release -o /app...