7e34d7c2d5
.dockerignore keeps .git/ out of the build context, so the in-container publish had no repository and AssemblyInformationalVersion (service.version, VersionInfo) was a bare 1.0.0. docker/build.sh (used by docker/deploy.sh and docker-env2/deploy.sh) now passes git rev-parse HEAD, suffixed -dirty for an uncommitted tree, and the Dockerfile hands it to dotnet publish as SourceRevisionId. Without the arg the build still succeeds as 1.0.0. The ARG sits after the source COPY so a new commit does not bust the restore layer. Claude-Session: https://claude.ai/code/session_01GT67ACmpMR7b9LGRPLijMi
74 lines
5.0 KiB
Docker
74 lines
5.0 KiB
Docker
# Stage 1: Restore (cached when .csproj/.slnx files don't change)
|
|
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS restore
|
|
WORKDIR /src
|
|
|
|
# Copy all .csproj files first (rarely change) for restore layer caching
|
|
COPY src/ZB.MOM.WW.ScadaBridge.Commons/ZB.MOM.WW.ScadaBridge.Commons.csproj src/ZB.MOM.WW.ScadaBridge.Commons/
|
|
COPY src/ZB.MOM.WW.ScadaBridge.Host/ZB.MOM.WW.ScadaBridge.Host.csproj src/ZB.MOM.WW.ScadaBridge.Host/
|
|
COPY src/ZB.MOM.WW.ScadaBridge.TemplateEngine/ZB.MOM.WW.ScadaBridge.TemplateEngine.csproj src/ZB.MOM.WW.ScadaBridge.TemplateEngine/
|
|
COPY src/ZB.MOM.WW.ScadaBridge.DeploymentManager/ZB.MOM.WW.ScadaBridge.DeploymentManager.csproj src/ZB.MOM.WW.ScadaBridge.DeploymentManager/
|
|
COPY src/ZB.MOM.WW.ScadaBridge.SiteRuntime/ZB.MOM.WW.ScadaBridge.SiteRuntime.csproj src/ZB.MOM.WW.ScadaBridge.SiteRuntime/
|
|
COPY src/ZB.MOM.WW.ScadaBridge.DataConnectionLayer/ZB.MOM.WW.ScadaBridge.DataConnectionLayer.csproj src/ZB.MOM.WW.ScadaBridge.DataConnectionLayer/
|
|
COPY src/ZB.MOM.WW.ScadaBridge.Communication/ZB.MOM.WW.ScadaBridge.Communication.csproj src/ZB.MOM.WW.ScadaBridge.Communication/
|
|
COPY src/ZB.MOM.WW.ScadaBridge.StoreAndForward/ZB.MOM.WW.ScadaBridge.StoreAndForward.csproj src/ZB.MOM.WW.ScadaBridge.StoreAndForward/
|
|
COPY src/ZB.MOM.WW.ScadaBridge.ExternalSystemGateway/ZB.MOM.WW.ScadaBridge.ExternalSystemGateway.csproj src/ZB.MOM.WW.ScadaBridge.ExternalSystemGateway/
|
|
COPY src/ZB.MOM.WW.ScadaBridge.NotificationService/ZB.MOM.WW.ScadaBridge.NotificationService.csproj src/ZB.MOM.WW.ScadaBridge.NotificationService/
|
|
COPY src/ZB.MOM.WW.ScadaBridge.CentralUI/ZB.MOM.WW.ScadaBridge.CentralUI.csproj src/ZB.MOM.WW.ScadaBridge.CentralUI/
|
|
COPY src/ZB.MOM.WW.ScadaBridge.CentralUI.SandboxWorker/ZB.MOM.WW.ScadaBridge.CentralUI.SandboxWorker.csproj src/ZB.MOM.WW.ScadaBridge.CentralUI.SandboxWorker/
|
|
COPY src/ZB.MOM.WW.ScadaBridge.Security/ZB.MOM.WW.ScadaBridge.Security.csproj src/ZB.MOM.WW.ScadaBridge.Security/
|
|
COPY src/ZB.MOM.WW.ScadaBridge.HealthMonitoring/ZB.MOM.WW.ScadaBridge.HealthMonitoring.csproj src/ZB.MOM.WW.ScadaBridge.HealthMonitoring/
|
|
COPY src/ZB.MOM.WW.ScadaBridge.SiteEventLogging/ZB.MOM.WW.ScadaBridge.SiteEventLogging.csproj src/ZB.MOM.WW.ScadaBridge.SiteEventLogging/
|
|
COPY src/ZB.MOM.WW.ScadaBridge.ClusterInfrastructure/ZB.MOM.WW.ScadaBridge.ClusterInfrastructure.csproj src/ZB.MOM.WW.ScadaBridge.ClusterInfrastructure/
|
|
COPY src/ZB.MOM.WW.ScadaBridge.InboundAPI/ZB.MOM.WW.ScadaBridge.InboundAPI.csproj src/ZB.MOM.WW.ScadaBridge.InboundAPI/
|
|
COPY src/ZB.MOM.WW.ScadaBridge.ConfigurationDatabase/ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.csproj src/ZB.MOM.WW.ScadaBridge.ConfigurationDatabase/
|
|
COPY src/ZB.MOM.WW.ScadaBridge.ManagementService/ZB.MOM.WW.ScadaBridge.ManagementService.csproj src/ZB.MOM.WW.ScadaBridge.ManagementService/
|
|
|
|
# Central Package Management: every .csproj declares versionless PackageReferences
|
|
# and the versions live in Directory.Packages.props. It must be present (above the
|
|
# projects) for `dotnet restore` to resolve versions — without it restore fails NU1015.
|
|
COPY Directory.Packages.props ./
|
|
|
|
# nuget.config declares the Gitea feed (and package-source mapping) that serves the
|
|
# ZB.MOM.WW.MxGateway.* packages used by the Data Connection Layer.
|
|
COPY nuget.config ./
|
|
|
|
# Optional credentials for the private Gitea feed, supplied at build time via
|
|
# --build-arg (see docker/build.sh). Left blank for an anonymous feed. NuGet reads
|
|
# per-source credentials from the NuGetPackageSourceCredentials_<sourceName> env var.
|
|
ARG NUGET_GITEA_USER=
|
|
ARG NUGET_GITEA_PASS=
|
|
ENV NuGetPackageSourceCredentials_dohertj2-gitea="Username=${NUGET_GITEA_USER};Password=${NUGET_GITEA_PASS}"
|
|
|
|
# Restore NuGet packages via Host project (follows ProjectReferences to all dependencies)
|
|
# This layer is cached until any .csproj changes — source-only changes skip restore entirely
|
|
RUN dotnet restore src/ZB.MOM.WW.ScadaBridge.Host/ZB.MOM.WW.ScadaBridge.Host.csproj
|
|
|
|
# Stage 2: Build + Publish
|
|
FROM restore AS build
|
|
COPY src/ src/
|
|
|
|
# Commit stamp (ScadaBridge#134). .dockerignore keeps .git/ out of the build context,
|
|
# so SourceLink has no repository to read and the informational version would be a
|
|
# bare "1.0.0". docker/build.sh passes the host's `git rev-parse HEAD` (plus "-dirty"
|
|
# for an uncommitted tree) and it is handed to the SDK as SourceRevisionId, which
|
|
# yields "1.0.0+<sha>" in AssemblyInformationalVersion (and so service.version / the
|
|
# Windows ProductVersion equivalent). Left empty, the build still succeeds as "1.0.0".
|
|
# Declared here, after the source COPY, so a new commit does not bust the restore layer.
|
|
ARG SOURCE_REVISION=
|
|
RUN dotnet publish src/ZB.MOM.WW.ScadaBridge.Host/ZB.MOM.WW.ScadaBridge.Host.csproj \
|
|
-c Release -o /app/publish \
|
|
${SOURCE_REVISION:+-p:SourceRevisionId=${SOURCE_REVISION}}
|
|
|
|
# Stage 3: Runtime (minimal image, no SDK)
|
|
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
|
|
WORKDIR /app
|
|
|
|
# Create data directory for SQLite databases (site nodes)
|
|
RUN mkdir -p /app/data /app/logs
|
|
|
|
COPY --from=build /app/publish .
|
|
|
|
EXPOSE 5000 8081 8082
|
|
|
|
ENTRYPOINT ["dotnet", "ZB.MOM.WW.ScadaBridge.Host.dll"]
|