# OPC UA ConsoleReferenceServer sample image. # # The build context must be the repository ROOT so the project references resolve. # Build directly: # docker build -f samples/Reference/ConsoleReferenceServer/Dockerfile -t opcua-reference-server . # # The SDK stages always run on the build platform ($BUILDPLATFORM): the # publish output is portable IL, so a multi-platform build never compiles # under emulation. Images CI publishes every sample once in a native pre-job # and selects the "prebuilt" stage instead, so the image legs only copy files: # --build-arg PUBLISH_SOURCE=prebuilt --build-arg PUBLISH_DIR= ARG PUBLISH_SOURCE=build FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0-azurelinux3.0 AS restore WORKDIR /src # copy csproj and restore as distinct layers COPY *.* . COPY ["samples/Reference/ConsoleReferenceServer/ConsoleReferenceServer.csproj", "samples/Reference/ConsoleReferenceServer/"] # The generator projects import shared MSBuild logic; restore fails with # "Invalid framework identifier ''" if these are not part of the restore layer. COPY ["tools/SourceGeneratorVariant.targets", "tools/"] COPY ["tools/Opc.Ua.SourceGeneration.Core/Opc.Ua.SourceGeneration.Core.csproj", "tools/Opc.Ua.SourceGeneration.Core/"] COPY ["tools/Opc.Ua.SourceGeneration.Stack/Opc.Ua.SourceGeneration.Stack.csproj", "tools/Opc.Ua.SourceGeneration.Stack/"] COPY ["tools/Opc.Ua.SourceGeneration.Stack/Opc.Ua.SourceGeneration.Stack.Sources.targets", "tools/Opc.Ua.SourceGeneration.Stack/"] COPY ["tools/Opc.Ua.SourceGeneration/Opc.Ua.SourceGeneration.csproj", "tools/Opc.Ua.SourceGeneration/"] COPY ["tools/Opc.Ua.SourceGeneration/Opc.Ua.SourceGeneration.Sources.targets", "tools/Opc.Ua.SourceGeneration/"] COPY ["src/Opc.Ua.Core.Types/Opc.Ua.Core.Types.csproj", "src/Opc.Ua.Core.Types/"] COPY ["src/Opc.Ua.Core/Opc.Ua.Core.csproj", "src/Opc.Ua.Core/"] COPY ["src/Opc.Ua.Core.Schema/Opc.Ua.Core.Schema.csproj", "src/Opc.Ua.Core.Schema/"] COPY ["src/Opc.Ua.Core.Diagnostics/Opc.Ua.Core.Diagnostics.csproj", "src/Opc.Ua.Core.Diagnostics/"] COPY ["src/Opc.Ua.Bindings.Https/Opc.Ua.Bindings.Https.csproj", "src/Opc.Ua.Bindings.Https/"] COPY ["src/Opc.Ua.Types/Opc.Ua.Types.csproj", "src/Opc.Ua.Types/"] COPY ["src/Opc.Ua.Security.Certificates/Opc.Ua.Security.Certificates.csproj", "src/Opc.Ua.Security.Certificates/"] COPY ["src/Opc.Ua.Client/Opc.Ua.Client.csproj", "src/Opc.Ua.Client/"] COPY ["src/Opc.Ua.Configuration/Opc.Ua.Configuration.csproj", "src/Opc.Ua.Configuration/"] COPY ["src/Opc.Ua.Server/Opc.Ua.Server.csproj", "src/Opc.Ua.Server/"] COPY ["samples/Quickstarts.Servers/Quickstarts.Servers.csproj", "samples/Quickstarts.Servers/"] COPY ["src/Opc.Ua.Gds/Opc.Ua.Gds.csproj", "src/Opc.Ua.Gds/"] COPY ["src/Opc.Ua.Gds.Server/Opc.Ua.Gds.Server.csproj", "src/Opc.Ua.Gds.Server/"] ENV DOTNET_EnableWriteXorExecute=0 RUN dotnet restore "samples/Reference/ConsoleReferenceServer/ConsoleReferenceServer.csproj" --force -p:CustomTestTarget=net10.0 COPY . . WORKDIR "/src/samples/Reference/ConsoleReferenceServer" ARG Version ARG SimpleVersion ARG InformationalVersion ENV OPTIONS="-c Release -f net10.0 -p:PublishAot=false -p:Dockerbuild=true -p:Version=${Version} -p:AssemblyVersion=${SimpleVersion} -p:FileVersion=${Version} -p:InformationalVersion=${InformationalVersion} -p:CustomTestTarget=net10.0" FROM restore AS build ENV DOTNET_EnableWriteXorExecute=0 RUN dotnet publish "ConsoleReferenceServer.csproj" --no-restore ${OPTIONS} -p:UseAppHost=false -o /app/publish FROM scratch AS prebuilt ARG PUBLISH_DIR=artifacts/docker/publish COPY ${PUBLISH_DIR}/ /app/publish/ FROM ${PUBLISH_SOURCE} AS publish FROM mcr.microsoft.com/dotnet/aspnet:10.0-azurelinux3.0-distroless-extra AS final WORKDIR /app COPY --from=publish /app/publish . EXPOSE 62541 ENTRYPOINT ["dotnet", "ConsoleReferenceServer.dll"]