#39805·wazuh

Publish the devContainer image to ghcr and document how to work with it

Author: juliancnnCreated Oct 1, 2026Updated Oct 1, 2026
Labelstype/testlevel/taskrequest/operational

Description

The Wazuh Manager devContainer (tools/devContainer/) is built locally on every machine the first time it is opened. The devcontainer.json builds tools/devContainer/.devcontainer/Dockerfile (tools/devContainer/.devcontainer/devcontainer.json:5) and installs six devcontainer features on top of it (tools/devContainer/.devcontainer/devcontainer.json:9). That build compiles clang-format from the LLVM sources, CMake 3.30.5 and mdbook, so the first start takes a long time. It is repeated on every Linux x64 and macOS ARM machine that uses the devContainer.

The clang-format built into the image does not match the one the CI uses. The Dockerfile builds llvmorg-22.1.4 (tools/devContainer/.devcontainer/Dockerfile:4). The coding style check downloads the Wazuh clang-format package (.github/actions/clang_format/action.yml:32), and that binary is clang-format 22.1.1.

download_devContainer.sh does not tell the user anything about GitHub access. The README only lists Docker and Git as prerequisites, says that the setup only works on Linux (tools/devContainer/README.md:53), and does not explain how the image is built or how to change it.

The image should be built once by the CI and pulled by developers. Changing the image and testing it locally before the CI builds it must stay simple.

Objectives

  • Opening the devContainer pulls a prebuilt image instead of building it, on Linux x64 and on macOS ARM.
  • The image is built and published by a GitHub Actions workflow.
  • A developer can rebuild the image locally with one command and open the devContainer on it without publishing anything.
  • The clang-format inside the devContainer is the same version the CI uses.
  • The README explains how to work with the devContainer.

Requirements

  • Publish the image as ghcr.io/wazuh/wazuh-devcontainer:5.0, a single multi-architecture tag (linux/amd64 and linux/arm64). The tag is the major.minor of VERSION.json.
  • Build each architecture on a native runner (ubuntu-24.04 and ubuntu-24.04-arm), without emulation.
  • The image contains the Dockerfile and the current features, so opening the devContainer does not run any build step.
  • Run the workflow on pushes to the 5.x.y and main branches that change tools/devContainer/.devcontainer/ or the workflow itself, and on workflow_dispatch. It does not run on pull requests.
  • Derive the image owner from the repository that runs the workflow, so a fork publishes to its own namespace and the workflow can be tested there.
  • Reuse the layers of the published image as build cache, so a run that does not change the Dockerfile does not rebuild clang-format.
  • Delete the untagged package versions that each build leaves behind, without deleting the platform manifests referenced by the current tag.
  • Keep a single definition of the image. The environment settings of the devContainer (remoteEnv, lifecycle commands, VS Code customizations) are not duplicated.
  • Provide one build script used both by the workflow and by developers. Run locally, it builds the image for the host architecture and loads it into the local Docker under the same tag, so the devContainer opens on it. docker pull restores the published image. An image label records whether an image was built locally or by the CI.
  • The package is private. Before creating the destination folder, download_devContainer.sh must:
    • check that the image is accessible;
    • if it is not, explain why and offer to log in to ghcr.io, either through the GitHub CLI with the read:packages scope or with a personal access token read from standard input;
    • pull the image. Tokens are never passed as command-line arguments or written to files. If access still fails, the script exits with an error and leaves no destination folder behind.
  • The devcontainer.json downloaded with -b <branch> points to the image tag of that branch.
  • The image repository can be overridden through an environment variable, both in download_devContainer.sh and in the build script, so a fork can be tested before merging.
  • download_devContainer.sh works on macOS, which rules out GNU-only sed -i.
  • Build clang-format llvmorg-22.1.1 in the Dockerfile, and use it as the default of tools/devContainer/.devcontainer/reinstall-clang-format.sh.

Deliverables

  • A workflow that builds both architectures and publishes the multi-architecture 5.0 tag.
  • The devContainer configuration using the published image, and the build script for local and CI builds.
  • download_devContainer.sh with the access check, the login offer, the pull and the image tag of the downloaded branch.
  • clang-format 22.1.1 in the image.
  • tools/devContainer/README.md updated with: supported platforms (Linux x64 and macOS ARM), prerequisites including GitHub access to the package, how to log in to ghcr.io, what the download script does, the first start, how to update to the latest image, how to modify and test the image locally, and how the image is published.
  • Evidence: the workflow run in a fork with both architectures, and the devContainer opened from the pulled image with the expected tools (clang-format 22.1.1, CMake 3.30.5, Docker-in-Docker).