From 42008d3c4d9e72ee4619f89920917489f591e910 Mon Sep 17 00:00:00 2001 From: mahan Date: Tue, 10 Feb 2026 15:20:36 +0330 Subject: [PATCH] complete docker v1 --- .../CompanyManagment.App.Contracts.csproj | 8 +- .../IInstitutionContractApplication.cs | 3 +- ServiceHost/Dockerfile | 78 ------------------- ServiceHost/Program.cs | 2 +- docker-compose.yml | 4 +- 5 files changed, 12 insertions(+), 83 deletions(-) delete mode 100644 ServiceHost/Dockerfile diff --git a/CompanyManagment.App.Contracts/CompanyManagment.App.Contracts.csproj b/CompanyManagment.App.Contracts/CompanyManagment.App.Contracts.csproj index 84e6cbda..f1d43aad 100644 --- a/CompanyManagment.App.Contracts/CompanyManagment.App.Contracts.csproj +++ b/CompanyManagment.App.Contracts/CompanyManagment.App.Contracts.csproj @@ -2,7 +2,7 @@ net10.0 - false + true $(NoWarn);1591 false @@ -20,4 +20,10 @@ + + + + diff --git a/CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs b/CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs index 1978e034..6819ffef 100644 --- a/CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs +++ b/CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs @@ -79,13 +79,12 @@ public interface IInstitutionContractApplication /// لیست قراردادها برای چاپ List PrintAll(List id); - - [Obsolete("استفاده نشود، از متد غیرهمزمان استفاده شود")] /// /// چاپ یک قرارداد /// /// شناسه قرارداد /// اطلاعات قرارداد برای چاپ + [Obsolete("استفاده نشود، از متد غیرهمزمان استفاده شود")] InstitutionContractViewModel PrintOne(long id); /// diff --git a/ServiceHost/Dockerfile b/ServiceHost/Dockerfile deleted file mode 100644 index 7b6213f3..00000000 --- a/ServiceHost/Dockerfile +++ /dev/null @@ -1,78 +0,0 @@ - -# Multi-stage build for ASP.NET Core 10 -FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build - -WORKDIR /src. - -# Copy solution and project files -COPY ["DadmehrGostar.sln", "DadmehrGostar.sln"] -COPY ["ServiceHost/ServiceHost.csproj", "ServiceHost/"] -COPY ["0_Framework/0_Framework.csproj", "0_Framework/"] -COPY ["_0_Framework/_0_Framework_b.csproj", "_0_Framework/"] -COPY ["AccountManagement.Application/AccountManagement.Application.csproj", "AccountManagement.Application/"] -COPY ["AccountManagement.Application.Contracts/AccountManagement.Application.Contracts.csproj", "AccountManagement.Application.Contracts/"] -COPY ["AccountManagement.Configuration/AccountManagement.Configuration.csproj", "AccountManagement.Configuration/"] -COPY ["AccountManagement.Domain/AccountManagement.Domain.csproj", "AccountManagement.Domain/"] -COPY ["AccountMangement.Infrastructure.EFCore/AccountMangement.Infrastructure.EFCore.csproj", "AccountMangement.Infrastructure.EFCore/"] -COPY ["BackgroundInstitutionContract/BackgroundInstitutionContract.Task/BackgroundInstitutionContract.Task.csproj", "BackgroundInstitutionContract/BackgroundInstitutionContract.Task/"] -COPY ["Company.Domain/Company.Domain.csproj", "Company.Domain/"] -COPY ["CompanyManagement.Infrastructure.Excel/CompanyManagement.Infrastructure.Excel.csproj", "CompanyManagement.Infrastructure.Excel/"] -COPY ["CompanyManagement.Infrastructure.Mongo/CompanyManagement.Infrastructure.Mongo.csproj", "CompanyManagement.Infrastructure.Mongo/"] -COPY ["CompanyManagment.App.Contracts/CompanyManagment.App.Contracts.csproj", "CompanyManagment.App.Contracts/"] -COPY ["CompanyManagment.Application/CompanyManagment.Application.csproj", "CompanyManagment.Application/"] -COPY ["CompanyManagment.EFCore/CompanyManagment.EFCore.csproj", "CompanyManagment.EFCore/"] -COPY ["PersonalContractingParty.Config/PersonalContractingParty.Config.csproj", "PersonalContractingParty.Config/"] -COPY ["ProgramManager/src/Application/GozareshgirProgramManager.Application/GozareshgirProgramManager.Application.csproj", "ProgramManager/src/Application/GozareshgirProgramManager.Application/"] -COPY ["ProgramManager/src/Domain/GozareshgirProgramManager.Domain/GozareshgirProgramManager.Domain.csproj", "ProgramManager/src/Domain/GozareshgirProgramManager.Domain/"] -COPY ["ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/GozareshgirProgramManager.Infrastructure.csproj", "ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/"] -COPY ["Query/Query.csproj", "Query/"] -COPY ["Query.Bootstrapper/Query.Bootstrapper.csproj", "Query.Bootstrapper/"] -COPY ["Shared.Contracts/Shared.Contracts.csproj", "Shared.Contracts/"] -COPY ["WorkFlow/Application/WorkFlow.Application/WorkFlow.Application.csproj", "WorkFlow/Application/WorkFlow.Application/"] -COPY ["WorkFlow/Application/WorkFlow.Application.Contracts/WorkFlow.Application.Contracts.csproj", "WorkFlow/Application/WorkFlow.Application.Contracts/"] -COPY ["WorkFlow/Domain/WorkFlow.Domain/WorkFlow.Domain.csproj", "WorkFlow/Domain/WorkFlow.Domain/"] -COPY ["WorkFlow/Infrastructure/WorkFlow.Infrastructure.ACL/WorkFlow.Infrastructure.ACL.csproj", "WorkFlow/Infrastructure/WorkFlow.Infrastructure.ACL/"] -COPY ["WorkFlow/Infrastructure/WorkFlow.Infrastructure.Config/WorkFlow.Infrastructure.Config.csproj", "WorkFlow/Infrastructure/WorkFlow.Infrastructure.Config/"] -COPY ["WorkFlow/Infrastructure/WorkFlow.Infrastructure.EfCore/WorkFlow.Infrastructure.EfCore.csproj", "WorkFlow/Infrastructure/WorkFlow.Infrastructure.EfCore/"] - -# Restore all projects -RUN dotnet restore "DadmehrGostar.sln" - -# Copy source code -COPY . . - -# Build the ServiceHost project -WORKDIR /src/ServiceHost -RUN dotnet build "ServiceHost.csproj" -c Release -o /app/build - -# Publish stage -FROM build AS publish -RUN dotnet publish "ServiceHost.csproj" -c Release -o /app/publish /p:UseAppHost=false - -# Runtime stage -FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final - -WORKDIR /app - -# Install curl for health checks -#RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* - -# Copy published app -COPY --from=publish /app/publish . - -# Create directories for certificates, storage, faces, and logs -# Note: Bind-mounted directories will override these, but we create them for consistency -RUN mkdir -p /app/certs /app/Faces /app/Storage /app/Logs app/InsuranceList && \ - chmod 777 /app/Faces /app/Storage /app/Logs app/InsuranceList && \ - chmod 755 /app/certs - -# Expose ports -EXPOSE 80 443 - -# Health check - check both HTTP and HTTPS -#HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ -# CMD curl -f http://localhost:80/health || curl -f -k https://localhost:443/health || exit 1 - -# Set entry point -ENTRYPOINT ["dotnet", "ServiceHost.dll"] - diff --git a/ServiceHost/Program.cs b/ServiceHost/Program.cs index 943c6f9e..796db0ac 100644 --- a/ServiceHost/Program.cs +++ b/ServiceHost/Program.cs @@ -48,7 +48,7 @@ using Microsoft.OpenApi; // Corrected using for PhysicalFileProvider // Use Docker-compatible log path var logDirectory = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == Environments.Development - ? @"C:\Logs\Gozareshgir\" + ? @"C:\LogsGozareshgir\\" : "/app/Logs"; if (!Directory.Exists(logDirectory)) diff --git a/docker-compose.yml b/docker-compose.yml index 93690db3..5e720290 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,9 @@ services: build: context: . dockerfile: Dockerfile - container_name: gozareshgir-servicehost + network: host + container_name: gozareshgir-api + image: gozareshgir-api # ✅ Run as root to ensure write permissions to bind mounts user: "0:0" # ✅ All environment variables are now in ServiceHost/.env