diff --git a/Aberwyn/Dockerfile b/Aberwyn/Dockerfile index defcf32..c67a604 100644 --- a/Aberwyn/Dockerfile +++ b/Aberwyn/Dockerfile @@ -1,22 +1,27 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. - +# Base image for runtime FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base WORKDIR /app EXPOSE 80 EXPOSE 443 +# Image for building the project FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src -COPY ["Aberwyn/Aberwyn.csproj", "Aberwyn/"] -RUN dotnet restore "Aberwyn/Aberwyn.csproj" + +# Copy the .csproj and restore dependencies +COPY ["Aberwyn.csproj", "./"] +RUN dotnet restore "Aberwyn.csproj" + +# Copy everything else and build the app COPY . . -WORKDIR "/src/Aberwyn" RUN dotnet build "Aberwyn.csproj" -c Release -o /app/build +# Publish the app to the /app/publish folder FROM build AS publish RUN dotnet publish "Aberwyn.csproj" -c Release -o /app/publish +# Use the base runtime image to run the app FROM base AS final WORKDIR /app COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "Aberwyn.dll"] \ No newline at end of file +ENTRYPOINT ["dotnet", "Aberwyn.dll"]