From 8473d08d11e67542407d1b89a2be3c6733480bb2 Mon Sep 17 00:00:00 2001 From: gsayer Date: Tue, 8 Jul 2025 20:57:04 +0200 Subject: [PATCH 1/5] feat(backend): add Dockerfile for backend service --- Dockerfile | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8215d9b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +WORKDIR /src + +# copy solution and project files +COPY ["PayrollEngine.Backend.sln", "./"] +COPY ["Api/Api.Controller/Api.Controller.csproj", "Api/Api.Controller/"] +COPY ["Api/Api.Core/Api.Core.csproj", "Api/Api.Core/"] +COPY ["Api/Api.Map/Api.Map.csproj", "Api/Api.Map/"] +COPY ["Api/Api.Model/Api.Model.csproj", "Api/Api.Model/"] +COPY ["Backend.Controller/Backend.Controller.csproj", "Backend.Controller/"] +COPY ["Backend.Server/PayrollEngine.Backend.Server.csproj", "Backend.Server/"] +COPY ["Domain/Domain.Application/Domain.Application.csproj", "Domain/Domain.Application/"] +COPY ["Domain/Domain.Model/Domain.Model.csproj", "Domain/Domain.Model/"] +COPY ["Domain/Domain.Scripting/Domain.Scripting.csproj", "Domain/Domain.Scripting/"] +COPY ["Persistence/Persistence/Persistence.csproj", "Persistence/Persistence/"] +COPY ["Persistence/Persistence.SqlServer/Persistence.SqlServer.csproj", "Persistence/Persistence.SqlServer/"] + +# copy Directory.Build.props files +COPY ["Directory.Build.props", "./"] +COPY ["Api/Directory.Build.props", "Api/"] +COPY ["Domain/Directory.Build.props", "Domain/"] +COPY ["Persistence/Directory.Build.props", "Persistence/"] + +RUN dotnet restore "PayrollEngine.Backend.sln" + +# copy everything else +COPY . . +WORKDIR "/src/Backend.Server" +RUN dotnet publish "PayrollEngine.Backend.Server.csproj" -c Release -o /app/publish --no-restore + +# final stage +FROM mcr.microsoft.com/dotnet/aspnet:8.0 +WORKDIR /app +COPY --from=build /app/publish . +ENTRYPOINT ["dotnet", "PayrollEngine.Backend.Server.dll"] \ No newline at end of file From 71bfdc81eae20fb55af2555330f97372acd17b2c Mon Sep 17 00:00:00 2001 From: gsayer Date: Tue, 8 Jul 2025 21:38:12 +0200 Subject: [PATCH 2/5] feat: Dockerize application --- Directory.Build.props | 19 ++++++++++--------- Dockerfile | 30 ++++++++++++++---------------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 9dbd635..0a65c61 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,15 +4,16 @@ net9.0 0.9.0-beta.6 0.9.0 - - Jani Giannoudis - Software Consulting Giannoudis - 2025 Software Consulting Giannoudis - Payroll Engine Backend Server - https://payrollengine.org/ - https://github.com/Payroll-Engine/PayrollEngine.Backend.git - 1701;1702;8034;AD0001;RMG020;RMG012 - true + 0.9.0-beta.6 + Payroll Engine Backend + Payroll Engine GmbH + Payroll Engine + Copyright © 2024 + en + enable + + 1701;1702;8034;AD0001;RMG020;RMG012;CS8618 + false false diff --git a/Dockerfile b/Dockerfile index 8215d9b..32e5740 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,23 @@ -FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build WORKDIR /src # copy solution and project files COPY ["PayrollEngine.Backend.sln", "./"] -COPY ["Api/Api.Controller/Api.Controller.csproj", "Api/Api.Controller/"] -COPY ["Api/Api.Core/Api.Core.csproj", "Api/Api.Core/"] -COPY ["Api/Api.Map/Api.Map.csproj", "Api/Api.Map/"] -COPY ["Api/Api.Model/Api.Model.csproj", "Api/Api.Model/"] -COPY ["Backend.Controller/Backend.Controller.csproj", "Backend.Controller/"] +COPY ["Api/Api.Controller/PayrollEngine.Api.Controller.csproj", "Api/Api.Controller/"] +COPY ["Api/Api.Core/PayrollEngine.Api.Core.csproj", "Api/Api.Core/"] +COPY ["Api/Api.Map/PayrollEngine.Api.Map.csproj", "Api/Api.Map/"] +COPY ["Api/Api.Model/PayrollEngine.Api.Model.csproj", "Api/Api.Model/"] +COPY ["Backend.Controller/PayrollEngine.Backend.Controller.csproj", "Backend.Controller/"] COPY ["Backend.Server/PayrollEngine.Backend.Server.csproj", "Backend.Server/"] -COPY ["Domain/Domain.Application/Domain.Application.csproj", "Domain/Domain.Application/"] -COPY ["Domain/Domain.Model/Domain.Model.csproj", "Domain/Domain.Model/"] -COPY ["Domain/Domain.Scripting/Domain.Scripting.csproj", "Domain/Domain.Scripting/"] -COPY ["Persistence/Persistence/Persistence.csproj", "Persistence/Persistence/"] -COPY ["Persistence/Persistence.SqlServer/Persistence.SqlServer.csproj", "Persistence/Persistence.SqlServer/"] +COPY ["Domain/Domain.Application/PayrollEngine.Domain.Application.csproj", "Domain/Domain.Application/"] +COPY ["Domain/Domain.Model/PayrollEngine.Domain.Model.csproj", "Domain/Domain.Model/"] +COPY ["Domain/Domain.Scripting/PayrollEngine.Domain.Scripting.csproj", "Domain/Domain.Scripting/"] +COPY ["Persistence/Persistence/PayrollEngine.Persistence.csproj", "Persistence/Persistence/"] +COPY ["Persistence/Persistence.SqlServer/PayrollEngine.Persistence.SqlServer.csproj", "Persistence/Persistence.SqlServer/"] +COPY ["Domain/Domain.Model.Tests/PayrollEngine.Domain.Model.Tests.csproj", "Domain/Domain.Model.Tests/"] # copy Directory.Build.props files COPY ["Directory.Build.props", "./"] -COPY ["Api/Directory.Build.props", "Api/"] -COPY ["Domain/Directory.Build.props", "Domain/"] -COPY ["Persistence/Directory.Build.props", "Persistence/"] RUN dotnet restore "PayrollEngine.Backend.sln" @@ -29,7 +27,7 @@ WORKDIR "/src/Backend.Server" RUN dotnet publish "PayrollEngine.Backend.Server.csproj" -c Release -o /app/publish --no-restore # final stage -FROM mcr.microsoft.com/dotnet/aspnet:8.0 +FROM mcr.microsoft.com/dotnet/aspnet:9.0 WORKDIR /app COPY --from=build /app/publish . -ENTRYPOINT ["dotnet", "PayrollEngine.Backend.Server.dll"] \ No newline at end of file +ENTRYPOINT ["dotnet", "PayrollEngine.Backend.Server.dll"] \ No newline at end of file From 7593e8180314f6261a91438ca1c46e478f7b5d08 Mon Sep 17 00:00:00 2001 From: gsayer Date: Wed, 9 Jul 2025 03:30:01 +0200 Subject: [PATCH 3/5] fix: Add missing ITenantService dependency injection registration - Add services.AddTransient() in ProviderStartupExtensions.cs - Fixes 'Unable to resolve service for type ITenantService' error in TenantController - Enables proper dependency injection for tenant-related API endpoints --- Backend.Server/ProviderStartupExtensions.cs | 1 + Dockerfile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Backend.Server/ProviderStartupExtensions.cs b/Backend.Server/ProviderStartupExtensions.cs index 9db005c..faf13bc 100644 --- a/Backend.Server/ProviderStartupExtensions.cs +++ b/Backend.Server/ProviderStartupExtensions.cs @@ -221,6 +221,7 @@ public static IServiceCollection AddLocalApiServices(this IServiceCollection ser ctx.GetRequiredService())); // tenant controllers + services.AddTransient(); services.AddTransient(ctx => new TenantController( ctx.GetRequiredService(), ctx.GetRequiredService(), diff --git a/Dockerfile b/Dockerfile index 32e5740..12b40ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,10 +11,10 @@ COPY ["Backend.Controller/PayrollEngine.Backend.Controller.csproj", "Backend.Con COPY ["Backend.Server/PayrollEngine.Backend.Server.csproj", "Backend.Server/"] COPY ["Domain/Domain.Application/PayrollEngine.Domain.Application.csproj", "Domain/Domain.Application/"] COPY ["Domain/Domain.Model/PayrollEngine.Domain.Model.csproj", "Domain/Domain.Model/"] +COPY ["Domain/Domain.Model.Tests/PayrollEngine.Domain.Model.Tests.csproj", "Domain/Domain.Model.Tests/"] COPY ["Domain/Domain.Scripting/PayrollEngine.Domain.Scripting.csproj", "Domain/Domain.Scripting/"] COPY ["Persistence/Persistence/PayrollEngine.Persistence.csproj", "Persistence/Persistence/"] COPY ["Persistence/Persistence.SqlServer/PayrollEngine.Persistence.SqlServer.csproj", "Persistence/Persistence.SqlServer/"] -COPY ["Domain/Domain.Model.Tests/PayrollEngine.Domain.Model.Tests.csproj", "Domain/Domain.Model.Tests/"] # copy Directory.Build.props files COPY ["Directory.Build.props", "./"] From c608eeb4c9fa44190d55f5cfe029f623b6bcaa21 Mon Sep 17 00:00:00 2001 From: gsayer Date: Wed, 9 Jul 2025 04:24:35 +0200 Subject: [PATCH 4/5] Fix compilation error: Add missing using statement for TenantService - Add 'using PayrollEngine.Domain.Application;' import to resolve TenantService compilation error - This fixes the Docker build failure in ProviderStartupExtensions.cs - Enables successful PayrollEngine backend compilation and deployment --- Backend.Server/ProviderStartupExtensions.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Backend.Server/ProviderStartupExtensions.cs b/Backend.Server/ProviderStartupExtensions.cs index faf13bc..e6e8fa1 100644 --- a/Backend.Server/ProviderStartupExtensions.cs +++ b/Backend.Server/ProviderStartupExtensions.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.DependencyInjection; using PayrollEngine.Api.Core; using PayrollEngine.Backend.Controller; +using PayrollEngine.Domain.Application; using PayrollEngine.Domain.Application.Service; using PayrollEngine.Domain.Model; From 7e8c705d467948d7ad3156880be20cb9fcbd0db6 Mon Sep 17 00:00:00 2001 From: gsayer Date: Sun, 13 Jul 2025 21:04:49 +0200 Subject: [PATCH 5/5] fix: resolve dotnet publish --no-restore issues with multi-architecture builds - Add BUILDPLATFORM and TARGETARCH support to Dockerfile - Use architecture-specific restore and publish commands - Remove problematic --no-restore flag to prevent NuGet resolution errors - Supports both ARM64 and x86_64 builds - Resolves build issues reported in PayrollEngine/PayrollEngine#2 --- Dockerfile | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 12b40ef..ec1fd97 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,7 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build +# Build stage with multi-platform support +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS build +ARG TARGETARCH +ARG BUILDPLATFORM WORKDIR /src # copy solution and project files @@ -19,12 +22,23 @@ COPY ["Persistence/Persistence.SqlServer/PayrollEngine.Persistence.SqlServer.csp # copy Directory.Build.props files COPY ["Directory.Build.props", "./"] -RUN dotnet restore "PayrollEngine.Backend.sln" +# Restore with architecture-specific runtime +RUN if [ "$TARGETARCH" = "arm64" ]; then \ + dotnet restore "PayrollEngine.Backend.sln" --runtime linux-arm64; \ + else \ + dotnet restore "PayrollEngine.Backend.sln" --runtime linux-x64; \ + fi # copy everything else COPY . . WORKDIR "/src/Backend.Server" -RUN dotnet publish "PayrollEngine.Backend.Server.csproj" -c Release -o /app/publish --no-restore + +# Publish with architecture-specific runtime and restore included +RUN if [ "$TARGETARCH" = "arm64" ]; then \ + dotnet publish "PayrollEngine.Backend.Server.csproj" -c Release -o /app/publish --runtime linux-arm64 --self-contained false; \ + else \ + dotnet publish "PayrollEngine.Backend.Server.csproj" -c Release -o /app/publish --runtime linux-x64 --self-contained false; \ + fi # final stage FROM mcr.microsoft.com/dotnet/aspnet:9.0