Skip to content

Commit 9c5e67b

Browse files
committed
distro: add rhel 8 and 9
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent 0c72998 commit 9c5e67b

File tree

11 files changed

+78
-18
lines changed

11 files changed

+78
-18
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# Same as ones in docker-bake.hcl
1616
DISTROS_DEB ?= debian11 debian12 debian13 ubuntu2204 ubuntu2404 raspbian11 raspbian12
17-
DISTROS_RPM ?= centos9 fedora37 fedora38 fedora39 oraclelinux8 oraclelinux9
17+
DISTROS_RPM ?= centos9 fedora37 fedora38 fedora39 oraclelinux8 oraclelinux9 rhel8 rhel9
1818
DISTROS_STATIC ?= static
1919
DISTROS ?= $(DISTROS_DEB) $(DISTROS_RPM) $(DISTROS_STATIC)
2020

docker-bake.hcl

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ variable "DISTROS" {
2828
"fedora38",
2929
"fedora39",
3030
"oraclelinux8",
31-
"oraclelinux9"
31+
"oraclelinux9",
32+
"rhel8",
33+
"rhel9"
3234
]
3335
}
3436

@@ -310,6 +312,28 @@ target "_distro-oraclelinux9" {
310312
}
311313
}
312314

315+
target "_distro-rhel8" {
316+
args = {
317+
DISTRO_NAME = "rhel8"
318+
DISTRO_TYPE = "rpm"
319+
DISTRO_RELEASE = "rhel"
320+
DISTRO_ID = "8"
321+
DISTRO_SUITE = "8"
322+
DISTRO_IMAGE = DISTRO_IMAGE != null ? DISTRO_IMAGE : "registry.access.redhat.com/ubi8/ubi"
323+
}
324+
}
325+
326+
target "_distro-rhel9" {
327+
args = {
328+
DISTRO_NAME = "rhel9"
329+
DISTRO_TYPE = "rpm"
330+
DISTRO_RELEASE = "rhel"
331+
DISTRO_ID = "9"
332+
DISTRO_SUITE = "9"
333+
DISTRO_IMAGE = DISTRO_IMAGE != null ? DISTRO_IMAGE : "registry.access.redhat.com/ubi9/ubi"
334+
}
335+
}
336+
313337
# Returns the list of supported platforms for a given distro and package.
314338
# The result is the intersection of the platforms supported by the distro
315339
# and the platforms supported by the package. Except for static distro,
@@ -334,6 +358,8 @@ function "distroPlatforms" {
334358
fedora39 = ["linux/amd64", "linux/arm64", "linux/ppc64le", "linux/s390x"]
335359
oraclelinux8 = ["linux/amd64", "linux/arm64"]
336360
oraclelinux9 = ["linux/amd64", "linux/arm64"]
361+
rhel8 = ["linux/amd64", "linux/arm64", "linux/ppc64le", "linux/s390x"]
362+
rhel9 = ["linux/amd64", "linux/arm64", "linux/ppc64le", "linux/s390x"]
337363
}, distro, []),
338364
pkgPlatforms(pkg)
339365
),
@@ -344,6 +370,12 @@ function "distroPlatforms" {
344370
)
345371
}
346372

373+
# Returns the list of secrets to use for a given distro.
374+
function "distroSecrets" {
375+
params = [distro]
376+
result = length(regexall("^rhel", distro)) > 0 ? ["type=env,id=RH_USER,env=RH_USER", "type=env,id=RH_PASS,env=RH_PASS"] : []
377+
}
378+
347379
#
348380
# pkgs configurations
349381
#
@@ -508,6 +540,7 @@ target "pkg" {
508540
# BAKE_LOCAL_PLATFORM is a built-in var returning the current platform's
509541
# default platform specification: https://docs.docker.com/build/customize/bake/file-definition/#built-in-variables
510542
platforms = LOCAL_PLATFORM != null ? [BAKE_LOCAL_PLATFORM] : distroPlatforms(distro, pkg)
543+
secret = distroSecrets(distro)
511544
attest = [
512545
"type=sbom",
513546
"type=provenance,mode=max"

hack/scripts/rpm-init.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,15 @@ case "$pkgrelease" in
5151
fedora*)
5252
dnf install -y git rpm-build rpmlint dnf-plugins-core
5353
;;
54+
rhel*)
55+
dnf install -y git rpm-build rpmlint dnf-plugins-core
56+
rm -f /etc/rhsm-host
57+
if [ -z "$RH_USER" ] || [ -z "$RH_PASS" ]; then
58+
echo "Either RH_USER or RH_PASS is not set. Running build without subscription."
59+
else
60+
subscription-manager register --username="${RH_USER}" --password="${RH_PASS}"
61+
subscription-manager repos --enable "codeready-builder-for-rhel-$(xx-info os-version | cut -d. -f1)-$(xx-info rhel-arch)-rpms"
62+
# dnf config-manager --set-enabled codeready-builder-for-rhel-$(xx-info os-version | cut -d. -f1)-$(xx-info rhel-arch)-rpms
63+
fi
64+
;;
5465
esac

pkg/buildx/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,13 @@ ENV GO111MODULE="on"
127127
ENV CGO_ENABLED="0"
128128
ARG DISTRO_NAME
129129
RUN --mount=type=bind,from=scripts,source=rpm-init.sh,target=/usr/local/bin/rpm-init \
130-
rpm-init $DISTRO_NAME
130+
--mount=type=secret,id=RH_USER,env=RH_USER \
131+
--mount=type=secret,id=RH_PASS,env=RH_PASS \
132+
rpm-init $DISTRO_NAME
131133
COPY rpm /root/rpmbuild/SPECS
132134
ARG TARGETPLATFORM
133135
RUN --mount=type=bind,from=scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep \
134-
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
136+
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
135137
WORKDIR /root/rpmbuild
136138
ARG NIGHTLY_BUILD
137139
ARG DISTRO_RELEASE

pkg/compose/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,13 @@ ENV GO111MODULE="on"
130130
ENV CGO_ENABLED="0"
131131
ARG DISTRO_NAME
132132
RUN --mount=type=bind,from=scripts,source=rpm-init.sh,target=/usr/local/bin/rpm-init \
133-
rpm-init $DISTRO_NAME
133+
--mount=type=secret,id=RH_USER,env=RH_USER \
134+
--mount=type=secret,id=RH_PASS,env=RH_PASS \
135+
rpm-init $DISTRO_NAME
134136
COPY rpm /root/rpmbuild/SPECS
135137
ARG TARGETPLATFORM
136138
RUN --mount=type=bind,from=scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep \
137-
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
139+
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
138140
WORKDIR /root/rpmbuild
139141
ARG NIGHTLY_BUILD
140142
ARG DISTRO_RELEASE

pkg/containerd/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,13 @@ ENV PATH="$PATH:/usr/local/go/bin:$GOPATH/bin"
184184
COPY --from=go-md2man /go/bin/go-md2man $GOPATH/bin/go-md2man
185185
ARG DISTRO_NAME
186186
RUN --mount=type=bind,from=scripts,source=rpm-init.sh,target=/usr/local/bin/rpm-init \
187-
rpm-init $DISTRO_NAME
187+
--mount=type=secret,id=RH_USER,env=RH_USER \
188+
--mount=type=secret,id=RH_PASS,env=RH_PASS \
189+
rpm-init $DISTRO_NAME
188190
COPY rpm /root/rpmbuild/SPECS
189191
ARG TARGETPLATFORM
190192
RUN --mount=type=bind,from=scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep \
191-
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
193+
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
192194
WORKDIR /root/rpmbuild
193195
ARG NIGHTLY_BUILD
194196
ARG DISTRO_RELEASE

pkg/credential-helpers/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,13 @@ ENV GOTOOLCHAIN="local"
129129
ENV GO111MODULE="on"
130130
ARG DISTRO_NAME
131131
RUN --mount=type=bind,from=scripts,source=rpm-init.sh,target=/usr/local/bin/rpm-init \
132-
rpm-init $DISTRO_NAME
132+
--mount=type=secret,id=RH_USER,env=RH_USER \
133+
--mount=type=secret,id=RH_PASS,env=RH_PASS \
134+
rpm-init $DISTRO_NAME
133135
COPY rpm /root/rpmbuild/SPECS
134136
ARG TARGETPLATFORM
135137
RUN --mount=type=bind,from=scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep \
136-
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
138+
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
137139
WORKDIR /root/rpmbuild
138140
ARG NIGHTLY_BUILD
139141
ARG DISTRO_RELEASE

pkg/docker-cli/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,13 @@ ENV GO111MODULE="off"
142142
ENV PATH="$PATH:/usr/local/go/bin:$GOPATH/bin"
143143
ARG DISTRO_NAME
144144
RUN --mount=type=bind,from=scripts,source=rpm-init.sh,target=/usr/local/bin/rpm-init \
145-
rpm-init $DISTRO_NAME
145+
--mount=type=secret,id=RH_USER,env=RH_USER \
146+
--mount=type=secret,id=RH_PASS,env=RH_PASS \
147+
rpm-init $DISTRO_NAME
146148
COPY rpm /root/rpmbuild/SPECS
147149
ARG TARGETPLATFORM
148150
RUN --mount=type=bind,from=scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep \
149-
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
151+
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
150152
WORKDIR /root/rpmbuild
151153
ARG NIGHTLY_BUILD
152154
ARG DISTRO_RELEASE

pkg/docker-engine/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,13 @@ ENV DOCKER_BUILDTAGS="seccomp selinux"
144144
ENV RUNC_BUILDTAGS="seccomp selinux"
145145
ARG DISTRO_NAME
146146
RUN --mount=type=bind,from=scripts,source=rpm-init.sh,target=/usr/local/bin/rpm-init \
147-
rpm-init $DISTRO_NAME
147+
--mount=type=secret,id=RH_USER,env=RH_USER \
148+
--mount=type=secret,id=RH_PASS,env=RH_PASS \
149+
rpm-init $DISTRO_NAME
148150
COPY rpm /root/rpmbuild/SPECS
149151
ARG TARGETPLATFORM
150152
RUN --mount=type=bind,from=scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep \
151-
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
153+
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
152154
WORKDIR /root/rpmbuild
153155
ARG NIGHTLY_BUILD
154156
ARG DISTRO_RELEASE

pkg/sbom/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,13 @@ ENV GO111MODULE="on"
127127
ENV CGO_ENABLED="0"
128128
ARG DISTRO_NAME
129129
RUN --mount=type=bind,from=scripts,source=rpm-init.sh,target=/usr/local/bin/rpm-init \
130-
rpm-init $DISTRO_NAME
130+
--mount=type=secret,id=RH_USER,env=RH_USER \
131+
--mount=type=secret,id=RH_PASS,env=RH_PASS \
132+
rpm-init $DISTRO_NAME
131133
COPY rpm /root/rpmbuild/SPECS
132134
ARG TARGETPLATFORM
133135
RUN --mount=type=bind,from=scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep \
134-
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
136+
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
135137
WORKDIR /root/rpmbuild
136138
ARG NIGHTLY_BUILD
137139
ARG DISTRO_RELEASE

0 commit comments

Comments
 (0)