diff --git a/wikidata_service/WikiDataTest/Dockerfile b/wikidata_service/WikiDataTest/Dockerfile index ab322a5..8e01f1f 100644 --- a/wikidata_service/WikiDataTest/Dockerfile +++ b/wikidata_service/WikiDataTest/Dockerfile @@ -1,26 +1,17 @@ -#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. - -#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed. -#For more information, please see https://aka.ms/containercompat - -FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base +# Use the official image as a parent image. +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env WORKDIR /app -EXPOSE 7259 -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -ARG BUILD_CONFIGURATION=Release -WORKDIR /src -COPY ["WikiDataTest/WikiDataTest.csproj", "WikiDataTest/"] -RUN dotnet restore "./WikiDataTest/./WikiDataTest.csproj" -COPY . . -WORKDIR "/src/WikiDataTest" -RUN dotnet build "./WikiDataTest.csproj" -c %BUILD_CONFIGURATION% -o /app/build +# Copy csproj and restore as distinct layers +COPY *.csproj ./ +RUN dotnet restore -FROM build AS publish -ARG BUILD_CONFIGURATION=Release -RUN dotnet publish "./WikiDataTest.csproj" -c %BUILD_CONFIGURATION% -o /app/publish /p:UseAppHost=false +# Copy everything else and build +COPY . ./ +RUN dotnet publish -c Release -o out -FROM base AS final +# Build runtime image +FROM mcr.microsoft.com/dotnet/aspnet:6.0 WORKDIR /app -COPY --from=publish /app/publish . +COPY --from=build-env /app/out . ENTRYPOINT ["dotnet", "WikiDataTest.dll"] \ No newline at end of file