Ahmed 10 months ago
parent
commit
e52c8cda8c
3 changed files with 37 additions and 8 deletions
  1. 9 7
      MTWorkHR.API/Dockerfile
  2. 27 0
      MTWorkHR.API/Dockerfile.original
  3. 1 1
      MTWorkHR.API/MTWorkHR.API.csproj

+ 9 - 7
MTWorkHR.API/Dockerfile

@@ -1,25 +1,27 @@
 #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:8.0-nanoserver-1809 AS base
+FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
+USER app
 WORKDIR /app
 EXPOSE 8080
 EXPOSE 8081
 
-FROM mcr.microsoft.com/dotnet/sdk:8.0-nanoserver-1809 AS build
+FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
 ARG BUILD_CONFIGURATION=Release
 WORKDIR /src
 COPY ["MTWorkHR.API/MTWorkHR.API.csproj", "MTWorkHR.API/"]
+COPY ["MTWorkHR.Application/MTWorkHR.Application.csproj", "MTWorkHR.Application/"]
+COPY ["MTWorkHR.Core/MTWorkHR.Core.csproj", "MTWorkHR.Core/"]
+COPY ["MTWorkHR.Identity/MTWorkHR.Identity.csproj", "MTWorkHR.Identity/"]
+COPY ["MTWorkHR.Infrastructure/MTWorkHR.Infrastructure.csproj", "MTWorkHR.Infrastructure/"]
 RUN dotnet restore "./MTWorkHR.API/./MTWorkHR.API.csproj"
 COPY . .
 WORKDIR "/src/MTWorkHR.API"
-RUN dotnet build "./MTWorkHR.API.csproj" -c %BUILD_CONFIGURATION% -o /app/build
+RUN dotnet build "./MTWorkHR.API.csproj" -c $BUILD_CONFIGURATION -o /app/build
 
 FROM build AS publish
 ARG BUILD_CONFIGURATION=Release
-RUN dotnet publish "./MTWorkHR.API.csproj" -c %BUILD_CONFIGURATION% -o /app/publish /p:UseAppHost=false
+RUN dotnet publish "./MTWorkHR.API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
 
 FROM base AS final
 WORKDIR /app

+ 27 - 0
MTWorkHR.API/Dockerfile.original

@@ -0,0 +1,27 @@
+#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:8.0-nanoserver-1809 AS base
+WORKDIR /app
+EXPOSE 8080
+EXPOSE 8081
+
+FROM mcr.microsoft.com/dotnet/sdk:8.0-nanoserver-1809 AS build
+ARG BUILD_CONFIGURATION=Release
+WORKDIR /src
+COPY ["MTWorkHR.API/MTWorkHR.API.csproj", "MTWorkHR.API/"]
+RUN dotnet restore "./MTWorkHR.API/./MTWorkHR.API.csproj"
+COPY . .
+WORKDIR "/src/MTWorkHR.API"
+RUN dotnet build "./MTWorkHR.API.csproj" -c %BUILD_CONFIGURATION% -o /app/build
+
+FROM build AS publish
+ARG BUILD_CONFIGURATION=Release
+RUN dotnet publish "./MTWorkHR.API.csproj" -c %BUILD_CONFIGURATION% -o /app/publish /p:UseAppHost=false
+
+FROM base AS final
+WORKDIR /app
+COPY --from=publish /app/publish .
+ENTRYPOINT ["dotnet", "MTWorkHR.API.dll"]

+ 1 - 1
MTWorkHR.API/MTWorkHR.API.csproj

@@ -6,7 +6,7 @@
     <ImplicitUsings>enable</ImplicitUsings>
     <InvariantGlobalization>false</InvariantGlobalization>
     <UserSecretsId>2b1d369c-a1e3-48bb-a35f-1b43b4e6c067</UserSecretsId>
-    <DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
+    <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
   </PropertyGroup>
 
   <ItemGroup>