# Description
Images CI took 45–100 min per image. The arm64 half of every
`linux/amd64,linux/arm64` build ran `dotnet restore` and `dotnet
publish` in an arm64 SDK container under QEMU. For `refserver`, publish
took 8 min natively for amd64 and 92 min emulated for arm64. On top of
that, every one of the 10 matrix legs recompiled the whole stack.
The output is framework-dependent portable IL, so the compile is now
done once, natively. The image legs only copy files onto the
per-platform runtime base image.
### Dockerfiles (all 10)
- **SDK stage runs on the build platform.** The `build` stage is pinned
to `--platform=$BUILDPLATFORM`. `-p:UseAppHost=false` keeps an x64 app
host out of the arm64 image.
- **New `prebuilt` stage.** It is chosen with a global `ARG
PUBLISH_SOURCE`, which defaults to `build`. Local `docker build` and the
`docker-compose` files are unchanged.
```dockerfile
FROM scratch AS prebuilt
ARG PUBLISH_DIR=artifacts/docker/publish
COPY ${PUBLISH_DIR}/ /app/publish/
FROM ${PUBLISH_SOURCE} AS publish
```
- **Pump: final-stage `RUN`s moved to a native stage.** The `sed` on
`openssl.cnf` and the `mkdir`/`chown`/`chmod` steps now run in a
`$BUILDPLATFORM` `layout` stage. The final stage copies `/layout/` to
`/`, so `/app` and `/diag` keep the `$APP_UID:0` owner and `g=u` mode
they had before. `openssl.cnf` therefore comes from the build-platform
base image. It is a plain config file, so it is expected to match
between architectures.
### `docker-image.yml`
- **Single image list.** The image list lives once, in `env.IMAGES`
(image, project, Dockerfile). `discover` emits it as the matrix.
- **New `publish-samples` job.** It runs `dotnet publish` for each
sample sequentially, so shared libraries compile once. It uses the same
options and NBGV version properties as the Dockerfiles and uploads the
output as the `docker-publish` artifact.
- **`build-and-push-image` legs.** Each leg:
- downloads the artifact;
- builds with `PUBLISH_SOURCE=prebuilt` and
`PUBLISH_DIR=artifacts/docker/publish/<image>`;
- no longer uses `setup-qemu-action`;
- is named `build-and-push-image (<image>)`.
- **`images summary`.** It now also fails when `publish-samples` fails.
### Docs
- `ContainerReferenceServer.md` describes the publish-once / copy-only
flow and the build arguments.
- `DeveloperGuide.md` mentions the `publish-samples` job in the Images
CI section.
Expected: one native publish of about 7 min, then 10 parallel
copy-and-push legs of a few minutes each. Not yet confirmed on CI: the
sandbox could not pull MCR base images, so the prebuilt multi-platform
builds were checked against a Debian-based stand-in base, and the
build-from-source path was not built.
## Related Issues
## Checklist
- [ ] I have signed the
[CLA](https://opcfoundation.org/license/cla/ContributorLicenseAgreementv1.0.pdf)
and read the
[CONTRIBUTING](https://github.com/OPCFoundation/UA-.NETStandard/blob/master/CONTRIBUTING.md)
doc.
- [ ] I have added tests that prove my fix is effective or that my
feature works and increased code coverage.
- [x] I have added all necessary documentation.
- [ ] I have verified that my changes do not introduce (new) build or
analyzer warnings.
- [ ] I ran **all** tests locally using the **UA.slnx** solution against
at least .net **framework** and .net **10**, and all passed.
- [ ] I fixed **all** failing and flaky tests in the CI pipelines and
**all** CodeQL warnings.
- [ ] I have addressed **all** PR feedback received.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
6.7 KiB
Container support and remote debugging for Reference Server
Overview
Run the Reference Server in a Docker container using a published image or a local build:
- Pull the latest or a release image from the GitHub Container Registry. These images support Linux targets.
- The image supports
amd64andarm64. The sample builds inside a container, so you do not need to install the .NET SDK. This change was introduced in this commit. - Build locally with Docker Desktop on Linux or Windows. Docker Desktop settings select the target container OS.
- Visual Studio 2019 and later include container support, but issues in the UA Reference solution currently prevent build, startup, or connection.
- Visual Studio 2022 supports native debugging of a Linux distribution through WSL.
Contents
- Overview
- Other published sample images
- Building the local containers
- Run the reference server container
- Known limitations and issues
Other published sample images
The Images CI workflow builds
and publishes the sample images below to the GitHub Container Registry
(ghcr.io/opcfoundation/uanetstandard/<image>). It builds each image for
linux/amd64 and linux/arm64.
| Image | Sample application |
|---|---|
refserver |
samples/Reference/ConsoleReferenceServer |
ldsserver |
samples/Lds/ConsoleLdsServer |
boilerserver |
samples/MinimalApi/MinimalBoilerServer |
calcserver |
samples/MinimalApi/MinimalCalcServer |
mcpserver |
tools/Opc.Ua.Mcp |
redundantserver |
samples/Redundancy/RedundantServer |
redundantclient |
samples/Redundancy/RedundantClient |
redundantpubsub |
samples/Redundancy/RedundantPubSub |
pubsubclient |
samples/PubSub/ConsoleReferencePubSubClient |
pumpserver |
samples/DI/PumpDeviceIntegrationServer |
The workflow does not compile anything under emulation. Its
publish-samples job publishes every sample above once, natively, as
framework-dependent portable IL (no runtime identifier and no app host). The
same output then runs on both platforms. Each build-and-push-image leg
downloads that output and builds its Dockerfile with
--build-arg PUBLISH_SOURCE=prebuilt --build-arg PUBLISH_DIR=<folder>. That
build only copies files onto the platform's .NET runtime base image, so QEMU
is not needed.
All sample Dockerfiles use the .NET 10 Azure Linux 3 SDK image for building and
an Azure Linux 3 distroless-extra runtime or ASP.NET image for the final image.
The distroless-extra variant retains ICU and time-zone data for globalization.
Pump and ModelManagementServer prepare writable directories and the OpenSSL
configuration in a regular Azure Linux layout stage before copying them into
their distroless final images.
A local docker build without these arguments compiles from source in the
Dockerfile's build stage. That stage is pinned to $BUILDPLATFORM, so a
multi-platform docker buildx build --platform linux/amd64,linux/arm64 also
compiles natively.
Image tags follow the release-branch-only publication model:
- Stable tags include
<image>:latest,<image>:release, and version tags such as<major>.<minor>and<major>.<minor>.<patch>. Update them only from a stable commit on a canonicalrelease/<major>.<minor>branch (see Release process). A preview build (-preview.N) does not move these tags. <image>:latest-<branch>(for examplerefserver:latest-master) tracks the most recent development build on that branch.Images CIbuilds these frommasterand fromrelease/*branches while they are pre-release.<image>:<version>(for examplerefserver:2.0.0-preview.6orrefserver:2.0.0) identifies the exact package version used to build the image, on any branch.
For example, pull the most recently approved stable Lds server image with:
docker pull ghcr.io/opcfoundation/uanetstandard/ldsserver:latest
Pull the most recent development build with:
docker pull ghcr.io/opcfoundation/uanetstandard/ldsserver:latest-master
Each application folder contains a Dockerfile. Build it from the repository root so the build can use the repository as context, for example:
docker build -f samples/Lds/ConsoleLdsServer/Dockerfile -t opcua-lds-server .
Building the local containers
- Open a command prompt which can execute docker commands.
- Navigate to the folder
samples/Reference/ConsoleReferenceServer. - Build the docker container by executing the command
dockerbuild.cmd.
On Linux,
- Open a shell which can execute docker commands.
- Navigate to the folder
samples/Reference/ConsoleReferenceServer. - Build the docker container by executing the command
./dockerbuild.sh.
Run the reference server container
Run the container in interactive mode with the host's hostname. The
certificate store, log output, and configuration file (when you use -s)
are mounted in ./OPC Foundation.
The container uses these paths by default:
- Certificate store:
./OPC Foundation/pki - Log file:
./OPC Foundation/Logs - Shadow configuration:
./OPC Foundation/Quickstarts.ReferenceServer.Config.xml
With -s, the container first copies the configuration file to the mounted
folder. On later restarts, the server reads this copy, so you can change the
settings there.
Run the local build of the Docker container
To run the local containers, batch files are provided called dockerrun.bat for Windows and dockerrun.sh for Linux.
Run the prebuilt Docker container hosted on GitHub
On Windows, open a command prompt and execute the following commands:
docker pull ghcr.io/opcfoundation/uanetstandard/refserver:latest
docker run -it -p 62541:62541 -h %COMPUTERNAME% -v "%CD%/OPC Foundation:/root/.local/share/OPC Foundation" ghcr.io/opcfoundation/uanetstandard/refserver:latest -c -s
On Linux, execute the following commands in a shell:
sudo docker pull ghcr.io/opcfoundation/uanetstandard/refserver:latest
sudo docker run -it -p 62541:62541 -h $HOSTNAME -v "$(pwd)/OPC Foundation:/root/.local/share/OPC Foundation" ghcr.io/opcfoundation/uanetstandard/refserver:latest -c -s
Known limitations and issues
- VS integrated docker build/debug support is not working with the Solution.