Repository navigation
Pull the package builder images from ghcr instead of building them - #1743
Merged
Merged
Conversation
Mount the builder scripts, spec, debian/, VERSION.json, plugins and run-with-retry.sh at run time, so each Dockerfile is the only input of its image. Tag every builder image as ghcr.io/wazuh/pkg_dashboard_<image>_builder_<arch>:<version>-<hash>, where <hash> is the short sha256 of the Dockerfile. build-packages.sh pulls that tag and builds it locally when the pull fails, so a missing tag or registry access keeps today's behavior. Generate packages logs in to ghcr with GITHUB_TOKEN to pull it. Signed-off-by: Diego Garcia <diego.garcia@wazuh.com>
Upload the base, rpm and deb builder images for amd64 and arm64 to ghcr when their Dockerfile changes on a version branch or main, or on demand. A tag that already exists is never pushed again. A weekly cleanup keeps the 3 latest versions of each image and deletes untagged ones. A branch whose tag was deleted builds the image locally. Signed-off-by: Diego Garcia <diego.garcia@wazuh.com>
- Cleanup: replace actions/delete-package-versions (keep the 3 latest) with a jq selection that deletes untagged versions and a tagged one only when all its tags are <version>-<hash> and none is the newest of its version. With 4 active version branches, "keep 3" deleted the image of one of them for good. A missing package now gives a notice instead of failing, and workflow_dispatch has a dry run. The filter has its own test script. - Upload: run on VERSION.json changes, since the tag holds the version. - build-packages.sh: try the pull twice before building locally, and warn in GitHub Actions when it falls back to the local build. - Delete the Docker/.gitignore files of base, rpm and deb: they only listed files that build-packages.sh no longer copies into the contexts. Signed-off-by: Diego Garcia <diego.garcia@wazuh.com>
The Generate packages job header also changes in the build-both-systems work, so granting packages: read for the whole workflow keeps both changes from conflicting. Jobs with their own permissions, like Test package, are not affected. Signed-off-by: Diego Garcia <diego.garcia@wazuh.com>
Mount the repository inputs with a shared SELinux label (z) so other containers that mount the repository keep access to them, wait 5s instead of 15s between pull attempts, since a local build without a ghcr login always falls back to building the images, and restore the Docker context .gitignore files. Signed-off-by: Diego Garcia <diego.garcia@wazuh.com>
✅ All unit and integration tests passing
|
This was referenced Nov 9, 2026
rodrigofez
approved these changes
Nov 9, 2026
rodrigofez
left a comment
Member
There was a problem hiding this comment.
Approve: Generate packages pulls the 3 published images on amd64 and arm64 and saves 2 to 8 minutes per job; the build-locally fallback keeps every other path working.
Tested ff3dacd7ed85. CI-only change, no UI, so no browser test. Read the CI logs of the runs in the PR body, ran the retention test, shellcheck, actionlint, and the pull fallback with docker stubbed. Couldn't list the ghcr versions: the packages are private and my token has no read:packages.
Requirements (#1707, point 2)
- 🟢 Publish base, rpm, deb for amd64 and arm64 to ghcr with
GITHUB_TOKEN, from GitHub-hosted runners: 42288344785, 6 jobs onubuntu-24.04/ubuntu-24.04-arm. - 🟢 Tags
<version>-<Dockerfile hash>, never overwritten: the Dockerfiles no longerADDanything, so the hash covers every input of the image. The "already exists" skip hasn't run in CI yet. - 🟢
Generate packagespulls, else builds: all 4 cells logUsing the published builder image; with the pull failing, the script builds the image and goes on. - 🟢 Weekly cleanup keeps each version branch's current image: 8 cases pass and the rule reads right. Not run against ghcr yet (it only runs from
main). - 🟢 Images hold build tools only.
Pull vs build (Generate packages, time to get the 2 builder images)
| Cell | 5.0.0: build the 2 images | PR: pull the 2 images |
|---|---|---|
| rpm x86_64 | 2m32s (42320462672) | 20s (42292063871) |
| deb amd64 | 3m37s (42654740775) | 31s (42292063871) |
| rpm aarch64 | 5m09s (42654757171) | 41s (42292067999) |
| deb arm64 | 9m07s (42654746290) | 54s (42292067999) |
Before merging
- Rebase and rerun one DEB cell. The DEB cells failed on the old
debian/changelog(built4.14.12-0), which #1745 fixed on5.0.0after this branch was cut.dpkg-buildpackagedid finish with the mounteddebian/, so the mounts work, but no DEB run is green yet. The CI runs also usedc473a49872(:Zmounts, default retry delay), not the head. - First cleanup run.
dry_rundefaults tofalse, and the first Monday after this reachesmaindeletes without a dry run unless someone dispatches one before. Low risk (only 1 upload has run, so each package should hold 1 version), butdefault: truewould match the plan in #1707.
Checks
bash dev-tools/build-packages/common/test-builder-image-retention.sh: 8 passed.shellcheckon the new scripts: 2 style notes (SC2001) in the test.build-packages.sh: no new warnings.actionlint 1.7.7: the 2 new workflows are clean; 5 warnings in5_builderpackage_dashboard.ymlare on lines this PR doesn't touch.builder-image.shon the head gives5.0.0-06292375c2b2(base),5bed341dd031(rpm),f782f2999ea8(deb): the tags the CI runs pulled.git merge-treewith #1737 and with5.0.0: no conflicts.- CI: Cypress jobs fail on every branch.
Build and Verify on Linux (ciGroup1): 3126 tests passed, then a Jest worker crashed (SIGSEGV). Not related; this PR changes no JS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Every
Generate packagesjob builds its 2 builder images from scratch (the base image, plus the RPM or the DEB one): 3m21s to 8m36s per job, and more when the yum or apt mirrors are slow. The images only hold build tools.This PR publishes the 3 builder images for amd64 and arm64 to ghcr, and makes
build-packages.shpull them. If an image can't be pulled, it builds it locally as today, so a registry outage or a missing image never fails a build. The design follows the review with DevOps in #1707.This PR covers the builder images part of the second task of #1707.
Related to #1707
Proposed Changes
ghcr.io/wazuh/pkg_dashboard_{base,rpm,deb}_builder_{amd64,arm64}, tagged<version>-<first 12 characters of the Dockerfile sha256>, for examplepkg_dashboard_rpm_builder_amd64:5.0.0-5bed341dd031.dev-tools/build-packages/common/builder-image.shcomputes the reference for the build and the workflows.ADDthe builder scripts, the spec,debian/,VERSION.json,pluginsorrun-with-retry.sh.build-packages.shmounts them read-only, with a shared SELinux label, where the builders already read them. The Dockerfile is the only input of an image, so a version bump or a spec change doesn't need a new image.build-packages.shpulls the image (2 attempts). If the pull fails, it builds the image locally under the same reference and, in CI, prints a::warning::. It never pushes. It still works locally without registry access.Generate packages: the workflow getspackages: read, and the job logs in to ghcr withGITHUB_TOKEN. A failed login doesn't stop the job. Job names, outputs and log lines don't change.5_builderprecompiled_dashboard_builder-images-upload.ymlruns on pushes tomainand the version branches that change a Dockerfile,builder-image.shorVERSION.json, and onworkflow_dispatch. It builds each image on a GitHub-hosted runner of its architecture (ubuntu-24.04,ubuntu-24.04-arm) and pushes it withGITHUB_TOKEN. Tags are immutable: if a tag exists, it skips it. It never runs on pull requests.5_builderprecompiled_dashboard_builder-images-cleanup.ymlruns weekly and onworkflow_dispatch(withdry_run). For each package it deletes the untagged versions and the versions superseded by a newer tag of the same version, so every version branch keeps its current image. The rule is incommon/builder-image-retention.jq, tested bycommon/test-builder-image-retention.sh.Results and Evidence
Publish: 42288344785 published the 6 images with
GITHUB_TOKEN, 2 to 3 minutes per image. The new workflow can't be dispatched until it's onmain, so it ran from itspushtrigger on a temporary test branch. The tags are the ones5.0.0will compute after the merge, so thepushrun on5.0.0will find them and skip them.Pull, on a temporary branch with this PR and #1737 merged,
system: both:Building the 2 images took 3m21s to 8m36s per job before.
Generate packages,Test packageandUpload package.dpkg-buildpackage: since Merge 4.14.12 into 5.0.0 #1740, the first entry ofdebian/changelogon5.0.0is4.14.12-RELEASE, so the package is built as4.14.12-0and the builder doesn't findwazuh-dashboard_5.0.0-0_amd64.deb. The changelog comes from5.0.0; this PR doesn't touch it.Cleanup: tested only with
ghstubbed. Itsscheduleandworkflow_dispatchtriggers only work once it's onmain. The first run should usedry_run.Local checks:
dockerstubbed, every input is mounted where its builder reads it. A failed pull falls back to a local build and the script exits 0.test-builder-image-retention.shpasses its 8 cases.ghstubbed, the cleanup deletes only the selected versions,dry_rundeletes nothing, and a package that doesn't exist yet only prints a notice.Artifacts Affected
None. The packages are built from the same inputs with the same tools.
Configuration Changes
6 new container packages in
ghcr.io/wazuh, linked to this repository.Documentation Updates
None.
Tests Introduced
dev-tools/build-packages/common/test-builder-image-retention.sh, for the retention rule.Review Checklist
no-changelog)