Skip to content

Commit f602ef3

Browse files
Merge pull request #2338 from aleksandrychev/ENT-13867
ENT-13867: Added RHEL 8,9,10 support to build in container
2 parents c5658dc + df8212f commit f602ef3

6 files changed

Lines changed: 139 additions & 15 deletions

File tree

.github/workflows/build-base-images.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ jobs:
2020
- debian-11
2121
- debian-12
2222
- debian-13
23+
- rhel-8
24+
- rhel-9
25+
- rhel-10
2326
steps:
2427
- name: Checkout repository
2528
uses: actions/checkout@v6

build-in-container-inner.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ for repo in $repos; do
3131
# regardless of the host directory layout.
3232
# Exclude acceptance test workdirs — they contain broken symlinks left
3333
# over from previous test runs and are not needed for building.
34+
# Also skip node_modules/vendor for hub builds.
3435
if [ -d "$src" ] || [ -L "$src" ]; then
3536
echo "Syncing $repo..."
36-
sudo rsync -aL --exclude='config.cache' --exclude='workdir' --chown="$(id -u):$(id -g)" "$src/" "$BASEDIR/$repo/"
37+
sudo rsync -aL --exclude='config.cache' --exclude='workdir' \
38+
--exclude='node_modules' --exclude='vendor' \
39+
--chown="$(id -u):$(id -g)" "$src/" "$BASEDIR/$repo/"
3740
else
3841
echo "ERROR: Required repository $repo not found" >&2
3942
exit 1

build-in-container.md

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,22 @@ None of the above arguments are required for `--update`.
5858

5959
## Supported platforms
6060

61-
| Name | Base image |
62-
| ----------- | -------------- |
63-
| `ubuntu-20` | `ubuntu:20.04` |
64-
| `ubuntu-22` | `ubuntu:22.04` |
65-
| `ubuntu-24` | `ubuntu:24.04` |
66-
| `debian-11` | `debian:11` |
67-
| `debian-12` | `debian:12` |
68-
| `debian-13` | `debian:13` |
61+
| Name | Base image |
62+
| ----------- | -------------------------- |
63+
| `ubuntu-20` | `ubuntu:20.04` |
64+
| `ubuntu-22` | `ubuntu:22.04` |
65+
| `ubuntu-24` | `ubuntu:24.04` |
66+
| `debian-11` | `debian:11` |
67+
| `debian-12` | `debian:12` |
68+
| `debian-13` | `debian:13` |
69+
| `rhel-8` | `rockylinux/rockylinux:8` |
70+
| `rhel-9` | `rockylinux/rockylinux:9` |
71+
| `rhel-10` | `rockylinux/rockylinux:10` |
72+
73+
RHEL packages are built on Rocky Linux base images. The build scripts detect
74+
`OS=rhel` from `/etc/redhat-release` (which reports `Rocky Linux release ...`),
75+
so the produced `.rpm`s are ordinary Red Hat / rpm packages. AlmaLinux is _not_
76+
recognized by `build-scripts/detect-environment`, which is why Rocky is used.
6977

7078
Adding a new Debian/Ubuntu platform requires a new entry in `platforms.json`
7179
and adding the platform name to the matrix in
@@ -85,8 +93,17 @@ The new entry in `platforms.json` needs:
8593
--platform <new-platform>` and it will fetch the current digest from
8694
Docker Hub and write it into `platforms.json`.
8795

88-
Adding a non-debian based platform (e.g.,
89-
RHEL/CentOS) requires a new `container/Dockerfile.rhel` plus platform entries.
96+
Adding another RHEL-family platform (a new Rocky/RHEL major version) works the
97+
same way: add a `platforms.json` entry with `"dockerfile": "Dockerfile.rhel"`
98+
and a matrix entry, then set any per-version `extra_build_args``CRB_REPO`
99+
(`powertools` on 8, `crb` on 9+), `PHP_MODULE_STREAM` (`remi-8.3` where the
100+
distro's default PHP is older than 8.3; RHEL 10 already ships 8.3), and
101+
`EXTRA_PKGS` for version-specific packages. Note that `--update-sha` also works
102+
for the namespaced `rockylinux/rockylinux` base images, not just official
103+
Docker Hub library images.
104+
105+
Adding an entirely different, non-RHEL/non-Debian platform family (e.g. SUSE)
106+
would require a new `container/Dockerfile.<family>` plus platform entries.
90107

91108
## How it works
92109

@@ -100,8 +117,10 @@ The system has three components:
100117
source repos from the read-only mount, then calls the existing build scripts
101118
in order.
102119

103-
3. **`container/Dockerfile.debian`** -- parameterized Dockerfile shared by all
104-
Debian/Ubuntu platforms via a `BASE_IMAGE` build arg.
120+
3. **`container/Dockerfile.debian`** and **`container/Dockerfile.rhel`** --
121+
parameterized Dockerfiles shared across platforms of the same family via a
122+
`BASE_IMAGE` build arg (plus per-platform `extra_build_args` in
123+
`platforms.json`, e.g. the CRB repo name and PHP module stream for RHEL).
105124

106125
### Container mounts
107126

build-in-container.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,12 @@ def update_platform_versions(platform_name=None):
195195
def latest_base_image_digest(base_image):
196196
"""Fetch current manifest digest from Docker Hub for a base image."""
197197
# Docker Hub's v2 API path requires a namespace. Official images (ubuntu,
198-
# debian, ...) live under "library/".
198+
# debian, ...) carry no namespace and live under "library/"; images that
199+
# already have an "org/name" namespace (e.g. rockylinux/rockylinux) are
200+
# used as-is.
199201
repo, tag = base_image.rsplit(":", 1)
200-
repo = f"library/{repo}"
202+
if "/" not in repo:
203+
repo = f"library/{repo}"
201204

202205
# The v2 API requires a bearer token even for anonymous public pulls.
203206
token_url = (

container/Dockerfile.rhel

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
ARG BASE_IMAGE=rockylinux/rockylinux:9
2+
FROM ${BASE_IMAGE}
3+
4+
# allow older packages when the newest has unmet deps (as build hosts do).
5+
RUN echo "best=False" >> /etc/dnf/dnf.conf
6+
7+
# Enable CRB (crb on 9+, powertools on 8) + EPEL for the -devel/build packages.
8+
ARG CRB_REPO=crb
9+
RUN dnf install -y dnf-plugins-core epel-release \
10+
&& dnf config-manager --set-enabled ${CRB_REPO} \
11+
&& dnf clean all
12+
13+
# Deps like zlib build without full debug symbols; disable debuginfo extraction
14+
# so rpm doesn't abort with "No debugging symbols". We don't ship debuginfo here.
15+
RUN echo '%debug_package %{nil}' > /etc/rpm/macros.cfengine-nodebug
16+
17+
# Build toolchain (see redhat section of ci/cfengine-build-host-setup.cf).
18+
# "Development Tools" provides gcc, make, autotools, rpm-build, core perl, etc.
19+
RUN dnf groupinstall -y "Development Tools" \
20+
&& dnf install -y \
21+
gcc-c++ pam-devel ncurses ncurses-devel expat expat-devel gettext \
22+
rpm-build-libs selinux-policy selinux-policy-devel \
23+
pkgconf pkgconf-pkg-config \
24+
perl perl-Module-Load-Conditional perl-ExtUtils-MakeMaker perl-IPC-Cmd \
25+
perl-IO-Compress \
26+
python3 python3-pip python3-devel \
27+
git rsync wget which psmisc unzip diffutils file sudo \
28+
&& dnf clean all
29+
30+
# Hub tools: Node 20 (system nodejs too old for the node: protocol) + less.
31+
RUN curl -fsSL https://rpm.nodesource.com/setup_20.x | bash - \
32+
&& dnf install -y nodejs \
33+
&& dnf clean all
34+
RUN npm install -g less
35+
36+
ARG PHP_MODULE_STREAM=""
37+
RUN if [ -n "${PHP_MODULE_STREAM}" ]; then \
38+
dnf install -y https://rpms.remirepo.net/enterprise/remi-release-$(rpm -E %rhel).rpm \
39+
&& dnf module reset -y php \
40+
&& dnf module enable -y php:${PHP_MODULE_STREAM}; \
41+
fi \
42+
&& dnf install -y php-cli php-xml php-mbstring \
43+
&& (dnf install -y php-json || true) \
44+
&& (dnf install -y php-zip || dnf install -y php-pecl-zip || true) \
45+
&& dnf clean all
46+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer.phar
47+
48+
# Rust + protobuf for the cargo-based leech2 dep (prebuilt tarballs, shared with Debian).
49+
COPY --from=ci linux-install-protobuf.sh linux-install-rust.sh /tmp/
50+
RUN /tmp/linux-install-protobuf.sh
51+
RUN /tmp/linux-install-rust.sh
52+
53+
# Per-version extras (rhel-8: cfbs py3_shebang_fix macro; rhel-10: patch).
54+
RUN if [ -n "${EXTRA_PKGS}" ]; then dnf install -y ${EXTRA_PKGS} && dnf clean all; fi
55+
56+
# Build user with passwordless sudo (needed by install-dependencies, package, etc.)
57+
RUN useradd -m -s /bin/bash builder \
58+
&& echo "builder ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/builder
59+
60+
USER builder
61+
WORKDIR /home/builder
62+
63+
# Pre-create so a volume mounted here is owned by builder, not root.
64+
RUN mkdir -p /home/builder/build

platforms.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,37 @@
4343
"base_image": "debian:13",
4444
"base_image_sha": "sha256:d07d1b51c39f51188e60be9b64e6bf769fa94e187f092bc32b91305cfa34ba5a",
4545
"dockerfile": "Dockerfile.debian"
46+
},
47+
"rhel-8": {
48+
"image_name": "cfengine-builder-rhel-8",
49+
"image_version": "latest",
50+
"base_image": "rockylinux/rockylinux:8",
51+
"base_image_sha": "sha256:e8a49c5403b687db05d4d67333fa45808fbe74f36e683cec7abb1f7d0f2338c6",
52+
"dockerfile": "Dockerfile.rhel",
53+
"extra_build_args": {
54+
"CRB_REPO": "powertools",
55+
"PHP_MODULE_STREAM": "remi-8.3",
56+
"EXTRA_PKGS": "python3-rpm-macros platform-python-devel"
57+
}
58+
},
59+
"rhel-9": {
60+
"image_name": "cfengine-builder-rhel-9",
61+
"image_version": "latest",
62+
"base_image": "rockylinux/rockylinux:9",
63+
"base_image_sha": "sha256:8101994123cf3d0a8fee517bee7f39e555c7d92bd2d9eb3303cc988a0eeed00f",
64+
"dockerfile": "Dockerfile.rhel",
65+
"extra_build_args": {
66+
"PHP_MODULE_STREAM": "remi-8.3"
67+
}
68+
},
69+
"rhel-10": {
70+
"image_name": "cfengine-builder-rhel-10",
71+
"image_version": "latest",
72+
"base_image": "rockylinux/rockylinux:10",
73+
"base_image_sha": "sha256:827d37bc128288ccf160ee318bb3cb92d591164cb217e92f8bc61e3982ae1834",
74+
"dockerfile": "Dockerfile.rhel",
75+
"extra_build_args": {
76+
"EXTRA_PKGS": "patch"
77+
}
4678
}
4779
}

0 commit comments

Comments
 (0)