-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (46 loc) · 1.98 KB
/
Dockerfile
File metadata and controls
53 lines (46 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Build stage with multi-platform support
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0 AS build
ARG TARGETARCH
ARG BUILDPLATFORM
ARG GITHUB_TOKEN
ARG NUGET_SOURCE=github
WORKDIR /src
# copy solution and project files
COPY ["PayrollEngine.WebApp.sln", "./"]
COPY ["Core/PayrollEngine.WebApp.Core.csproj", "Core/"]
COPY ["Presentation/PayrollEngine.WebApp.Presentation.csproj", "Presentation/"]
COPY ["Server/PayrollEngine.WebApp.Server.csproj", "Server/"]
COPY ["Shared/PayrollEngine.WebApp.Shared.csproj", "Shared/"]
COPY ["ViewModel/PayrollEngine.WebApp.ViewModel.csproj", "ViewModel/"]
# copy Directory.Build.props
COPY ["Directory.Build.props", "./"]
# Configure NuGet source
# NUGET_SOURCE=github (default): adds GitHub Packages — used for lib builds and dry-run
# NUGET_SOURCE=nuget.org: NuGet.org only — live app builds, identical to external PE users
RUN if [ "${NUGET_SOURCE}" = "github" ]; then \
dotnet nuget add source "https://nuget.pkg.github.com/Payroll-Engine/index.json" \
--name github \
--username github-actions \
--password ${GITHUB_TOKEN} \
--store-password-in-clear-text; \
fi
# Restore with architecture-specific runtime
RUN if [ "$TARGETARCH" = "arm64" ]; then \
dotnet restore "PayrollEngine.WebApp.sln" --runtime linux-arm64; \
else \
dotnet restore "PayrollEngine.WebApp.sln" --runtime linux-x64; \
fi
# copy everything else
COPY . .
WORKDIR "/src/Server"
# Publish with architecture-specific runtime and restore included
RUN if [ "$TARGETARCH" = "arm64" ]; then \
dotnet publish "PayrollEngine.WebApp.Server.csproj" -c Release -o /app/publish --runtime linux-arm64 --self-contained false; \
else \
dotnet publish "PayrollEngine.WebApp.Server.csproj" -c Release -o /app/publish --runtime linux-x64 --self-contained false; \
fi
# final stage
FROM mcr.microsoft.com/dotnet/aspnet:10.0
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "PayrollEngine.WebApp.Server.dll"]