From 32db287431716f7f72cf045f4a85b3b07e48ac9c Mon Sep 17 00:00:00 2001 From: Twinki Date: Tue, 3 Aug 2021 18:44:48 -0500 Subject: [PATCH] Cleanup Dockerfiles, add Dockerfile.dev that utilizes dotnet watch --- Dockerfile | 15 +++------------ Dockerfile.dev | 12 ++++++++++++ OSItemIndex.API.sln | 2 ++ 3 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 Dockerfile.dev diff --git a/Dockerfile b/Dockerfile index f04bf76..5b97492 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,9 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. - FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base -WORKDIR /app -FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build -WORKDIR . -COPY ["src/OSItemIndex.API/OSItemIndex.API.csproj", "src/OSItemIndex.API/"] -COPY ["src/OSItemIndex.Data/OSItemIndex.Data.csproj", "src/OSItemIndex.Data/"] -RUN dotnet restore "src/OSItemIndex.API/OSItemIndex.API.csproj" +FROM mcr.microsoft.com/dotnet/sdk:5.0 AS publish +WORKDIR /app COPY . . -WORKDIR "/src/OSItemIndex.API" -RUN dotnet build "OSItemIndex.API.csproj" -c Release -o /app/build - -FROM build AS publish +WORKDIR /app/src/OSItemIndex.API RUN dotnet publish "OSItemIndex.API.csproj" -c Release -o /app/publish FROM base AS final diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..6a44f3a --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,12 @@ +FROM mcr.microsoft.com/dotnet/sdk:5.0 AS base + +FROM mcr.microsoft.com/dotnet/sdk:5.0 AS publish +WORKDIR /app +COPY . . +WORKDIR /app/src/OSItemIndex.API +RUN dotnet restore + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/src . +ENTRYPOINT ["dotnet", "watch", "run", "-p", "OSItemIndex.API"] diff --git a/OSItemIndex.API.sln b/OSItemIndex.API.sln index a97b335..2264131 100644 --- a/OSItemIndex.API.sln +++ b/OSItemIndex.API.sln @@ -8,6 +8,8 @@ ProjectSection(SolutionItems) = preProject Dockerfile = Dockerfile ..\.env = ..\.env ..\docker-compose.dev.yml = ..\docker-compose.dev.yml + .dockerignore = .dockerignore + Dockerfile.dev = Dockerfile.dev EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OSItemIndex.API", "src\OSItemIndex.API\OSItemIndex.API.csproj", "{37059DD7-E108-44FC-9EFC-41BFC92F338B}"