concept event consumer in category .net

This is an excerpt from Manning's book Microservices in .NET Core, Second Edition.
Next up we build a container image for LoyaltyProgram microservice. The Loyalty Program has two parts: The API and the event consumer. We will build one container that is capable on running either as the API or the event consumer based on an environment variable. To do that we create a Dockerfile in the LoyaltyProgram code base where the
ENTRYPOINTis controlled by an environment variable:Listing 5.14. One docker image for the LoyaltyProgram which can run either the API of the event consumer
language="sql" linenumbering="unnumbered">FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build WORKDIR /src COPY . . RUN dotnet restore "LoyaltyProgram/LoyaltyProgram.csproj" RUN dotnet restore "EventConsumer/EventConsumer.csproj" WORKDIR "/src/LoyaltyProgram" RUN dotnet build "LoyaltyProgram.csproj" -c Release -o /api/build #1 WORKDIR "/src/EventConsumer" RUN dotnet build "EventConsumer.csproj" -c Release -o /consumer/build/consumer #2 FROM build AS publish WORKDIR "/src/LoyaltyProgram" RUN dotnet publish "LoyaltyProgram.csproj" -c Release -o /api/publish #3 WORKDIR "/src/EventConsumer" RUN dotnet publish "EventConsumer.csproj" -c Release -o /consumer/publish #4 FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS final WORKDIR /app EXPOSE 80 COPY --from=publish /api/publish ./api COPY --from=publish /consumer/publish ./consumer ENTRYPOINT dotnet $STARTUPDLL #5This Dockerfile is a little different from what we have seen before. The Dockerfiles we have seen before have built and published one ASP.NET Core application. This one builds and publishes an ASP.NET Core application - the Loyalty Program - and a .NET Core console application - the event consumer. The image built with this Dockerfile will therefore have both the
LoyaltyProgram.dlland theEventConsumer.dllin it. The last line of the Dockerfile,ENTRYPOINT dotnet $STARTUPDLLsays that when the images built with this Dockerfile starts up they should rundotneton whatever the environment variable$STARTUPDLLpoints to. So id$STARTUPDLLis equal to the path to theLoyaltyProgram.dllthe image will run the Loyalty Program API and it '$STARTUPDLL' is equal to the path to theEventConsumer.dllthe image will run the Loyalty Program event consumer.