Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"version": "8.0"
},
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"moby": false
"moby": false,
"installDockerBuildx": true
},
"ghcr.io/devcontainers/features/common-utils:2": {}
},
Expand Down
23 changes: 21 additions & 2 deletions .github/workflows/dotnet-build-and-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
Expand All @@ -35,6 +35,25 @@ jobs:
- name: Write Summary to GitHub Actions UI
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Login to Docker Hub
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and publish Docker images
uses: docker/bake-action@v7
with:
source: .
files: docker-bake.hcl
targets: default
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}

# Publish artifact only for main branch
- name: Publish CLI
if: github.ref_name == 'main'
Expand All @@ -51,4 +70,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: sos-linux-x64
path: ./publish
path: ./publish
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -397,4 +397,7 @@ FodyWeavers.xsd
# JetBrains Rider
*.sln.iml

*.lscache
*.lscache

# Local build outputs
/build/
52 changes: 49 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ whitespace is trimmed from configured values. The values below are neutral examp

| Environment variable | Used for | Example value |
| --- | --- | --- |
| `cmf_sos_registry` | npm registry where SoS image should be | `https://dev.criticalmanufacturing.io/repository/npm-public` |
| `cmf_sos_registry` | npm registry for the SoS package | `https://registry.npmjs.org/` |
| `cmf_sos_debug_image` | Dumps, runtime metrics, interactive shells, and Node.js remote debugging image | `criticalmanufacturing/sos:latest` |
| `cmf_sos_remote_debug_image` | .NET remote debugging image | `dev.criticalmanufacturing.io/platformengineering/sos-ubi:latest` |
| `cmf_sos_remote_debug_image` | .NET remote debugging image | `criticalmanufacturing/sos-ubi:latest` |
| `cmf_sos_symbol_server` | Base URL for .NET debugging symbols where SoS appends `/<appVersion>` | `https://symbolserver.apps.rhos.cm-mes.dev` |

Registry and symbol-server settings are HTTP(S) URLs. Debug-image settings are
Expand All @@ -72,4 +72,50 @@ cmf-sos

An explicit `--image` command-line option overrides the relevant debug-image
environment variable for that command. It does not change the npm registry or
symbol server.
symbol server.

## Building and publishing Docker images

Use Docker with the Buildx plugin and a running Docker daemon. The devcontainer
includes both; rebuild it to apply changes to its installed tooling.

From the repository root, build both images and load them into local Docker:

```bash
docker buildx bake --load
```

To build only one image:

```bash
docker buildx bake sos --load
# Or: docker buildx bake sos-ubi --load
```

To build and publish both images to Docker Hub:

```bash
docker login
docker buildx bake --push
```

The default targets are `criticalmanufacturing/sos:latest` and
`criticalmanufacturing/sos-ubi:latest`, both for `linux/amd64`. Configure the
registry, namespace, tag, and platform with environment variables:

| Variable | Default |
| --- | --- |
| `DOCKER_REGISTRY` | `docker.io` |
| `DOCKER_NAMESPACE` | `criticalmanufacturing` |
| `DOCKER_TAG` | `latest` |
| `DOCKER_PLATFORM` | `linux/amd64` |

For example, build both images with a different tag:

```bash
DOCKER_TAG=development docker buildx bake --load
```

Preview the resolved configuration with `docker buildx bake --print`. The CI
workflow builds both images on pushes and pull requests, and publishes both
only on pushes to `main` after the .NET checks pass.
33 changes: 33 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
variable "DOCKER_REGISTRY" {
default = "docker.io"
}

variable "DOCKER_NAMESPACE" {
default = "criticalmanufacturing"
}

variable "DOCKER_TAG" {
default = "latest"
}

variable "DOCKER_PLATFORM" {
default = "linux/amd64"
}

group "default" {
targets = ["sos", "sos-ubi"]
}

target "sos" {
context = "src/sidecar"
dockerfile = "Dockerfile"
tags = ["${DOCKER_REGISTRY}/${DOCKER_NAMESPACE}/sos:${DOCKER_TAG}"]
platforms = [DOCKER_PLATFORM]
}

target "sos-ubi" {
context = "src/sidecar/ubi"
dockerfile = "Dockerfile"
tags = ["${DOCKER_REGISTRY}/${DOCKER_NAMESPACE}/sos-ubi:${DOCKER_TAG}"]
platforms = [DOCKER_PLATFORM]
}
4 changes: 2 additions & 2 deletions src/app/Console/Utilities/RegistryConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ namespace Cmf.Cli.Plugin.Sos.Utilities;
/// <summary>External resource defaults shared by CLI and interactive operations.</summary>
public static class RegistryConfiguration
{
public static string NpmRegistry => Read("cmf_sos_registry", "https://dev.criticalmanufacturing.io/repository/npm-public");
public static string NpmRegistry => Read("cmf_sos_registry", "https://registry.npmjs.org/");
public static string DebugImage => Read("cmf_sos_debug_image", "criticalmanufacturing/sos:latest");
public static string RemoteDotnetDebugImage => Read("cmf_sos_remote_debug_image", "dev.criticalmanufacturing.io/platformengineering/sos-ubi:latest");
public static string RemoteDotnetDebugImage => Read("cmf_sos_remote_debug_image", "criticalmanufacturing/sos-ubi:latest");
public static string SymbolServer => Read("cmf_sos_symbol_server", "https://symbolserver.apps.rhos.cm-mes.dev");

private static string Read(string name, string fallback)
Expand Down
6 changes: 3 additions & 3 deletions src/app/Tests/Specs/RegistryConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ public class RegistryConfigurationTests
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
public void MissingOverridesKeepInternalDefaults(string? value)
public void MissingOverridesKeepDefaults(string? value)
{
WithEnvironment("cmf_sos_debug_image", value, () =>
Assert.Equal("criticalmanufacturing/sos:latest", RegistryConfiguration.DebugImage));
WithEnvironment("cmf_sos_remote_debug_image", value, () =>
Assert.Equal("dev.criticalmanufacturing.io/platformengineering/sos-ubi:latest", RegistryConfiguration.RemoteDotnetDebugImage));
Assert.Equal("criticalmanufacturing/sos-ubi:latest", RegistryConfiguration.RemoteDotnetDebugImage));
WithEnvironment("cmf_sos_registry", value, () =>
Assert.Equal("https://dev.criticalmanufacturing.io/repository/npm-public", RegistryConfiguration.NpmRegistry));
Assert.Equal("https://registry.npmjs.org/", RegistryConfiguration.NpmRegistry));
WithEnvironment("cmf_sos_symbol_server", value, () =>
Assert.Equal("https://symbolserver.apps.rhos.cm-mes.dev", RegistryConfiguration.SymbolServer));
}
Expand Down
8 changes: 6 additions & 2 deletions src/sidecar/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
ARG CMF_SOS_BASE_IMAGE=dev.criticalmanufacturing.io/platformengineering/ubuntu-base-24.04:latest
FROM ${CMF_SOS_BASE_IMAGE} AS sos
FROM ubuntu:24.04 AS sos

RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates apt-transport-https curl && \
sed -i.bak 's|http://|https://|g' /etc/apt/sources.list.d/ubuntu.sources && \
rm -rf /var/lib/apt/lists/*

ENV NODE_MAJOR=20
ENV DOTNET_SDK=8.0
Expand Down
Loading