Skip to content

Commit 65032d1

Browse files
authored
Merge pull request #991 from neersighted/rhel-poc
RHEL PoC
2 parents 0693b86 + 4c055ae commit 65032d1

File tree

5 files changed

+99
-3
lines changed

5 files changed

+99
-3
lines changed

Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ def genBuildStep(LinkedHashMap pkg, String arch) {
4242
stage("build") {
4343
checkout scm
4444
sh "make clean"
45-
sh "make REF=$branch ${pkg.target}"
45+
sh "make REF=$branch ARCH=${arch} ${pkg.target}"
4646
}
4747
stage("verify") {
48-
sh "make IMAGE=${pkg.image} verify"
48+
sh "make IMAGE=${pkg.image} ARCH=${arch} verify"
4949
}
5050
}
5151
}

deb/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ BUILD?=DOCKER_BUILDKIT=1 \
2222
--build-arg GO_IMAGE=$(GO_IMAGE) \
2323
--build-arg COMMON_FILES=$(COMMON_FILES) \
2424
-t debbuild-$@/$(ARCH) \
25+
--platform linux/$(ARCH) \
2526
-f $@/Dockerfile \
2627
.
2728

@@ -33,6 +34,7 @@ RUN_FLAGS=
3334
# see https://github.com/docker/docker-ce-packaging/pull/1006#issuecomment-2006878743
3435
RUN?=docker run --rm \
3536
--security-opt seccomp=unconfined \
37+
--platform linux/$(ARCH) \
3638
-e PLATFORM \
3739
-e EPOCH='$(EPOCH)' \
3840
-e DEB_VERSION=$(word 1, $(GEN_DEB_VER)) \

rpm/Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,19 @@ CLI_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/cli) &&
1010
ENGINE_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/docker) && git rev-parse --short HEAD)
1111
BUILDX_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/buildx) && git rev-parse --short HEAD)
1212

13+
ifdef RH_USER
14+
RH_FLAGS=--secret id=rh-user,env=RH_USER --secret id=rh-pass,env=RH_PASS
15+
endif
1316
ifdef BUILD_IMAGE
1417
BUILD_IMAGE_FLAG=--build-arg $(BUILD_IMAGE)
1518
endif
1619
BUILD?=DOCKER_BUILDKIT=1 \
1720
docker build \
21+
$(RH_FLAGS) \
1822
$(BUILD_IMAGE_FLAG) \
1923
--build-arg GO_IMAGE=$(GO_IMAGE) \
2024
-t rpmbuild-$@/$(ARCH) \
25+
--platform linux/$(ARCH) \
2126
-f $@/Dockerfile \
2227
.
2328

@@ -48,6 +53,7 @@ RUN_FLAGS=
4853
# https://github.com/docker/docker-ce-packaging/pull/1006#issuecomment-2006878743
4954
RUN?=docker run --rm \
5055
--security-opt seccomp=unconfined \
56+
--platform linux/$(ARCH) \
5157
-e PLATFORM \
5258
-v $(CURDIR)/rpmbuild/SOURCES:/root/rpmbuild/SOURCES:ro \
5359
-v $(CURDIR)/rpmbuild/$@/RPMS:/root/rpmbuild/RPMS \
@@ -57,7 +63,7 @@ RUN?=docker run --rm \
5763

5864
FEDORA_RELEASES ?= fedora-40 fedora-39
5965
CENTOS_RELEASES ?= centos-9
60-
RHEL_RELEASES ?=
66+
RHEL_RELEASES ?= rhel-8 rhel-9
6167

6268
DISTROS := $(FEDORA_RELEASES) $(CENTOS_RELEASES) $(RHEL_RELEASES)
6369
BUNDLES := $(patsubst %,rpmbuild/bundles-ce-%-$(DPKG_ARCH).tar.gz,$(DISTROS))

rpm/rhel-8/Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# syntax=docker/dockerfile:1
2+
3+
ARG GO_IMAGE
4+
ARG DISTRO=rhel
5+
ARG SUITE=8
6+
ARG BUILD_IMAGE=registry.access.redhat.com/ubi8/ubi
7+
8+
FROM ${GO_IMAGE} AS golang
9+
10+
FROM ${BUILD_IMAGE} AS subscribed-image
11+
RUN --mount=type=secret,id=rh-user --mount=type=secret,id=rh-pass <<-EOT
12+
rm -f /etc/rhsm-host
13+
14+
if [ ! -f /run/secrets/rh-user ] || [ ! -f /run/secrets/rh-pass ]; then
15+
echo "Either RH_USER or RH_PASS is not set. Running build without subscription."
16+
else
17+
subscription-manager register \
18+
--username="$(cat /run/secrets/rh-user)" \
19+
--password="$(cat /run/secrets/rh-pass)"
20+
21+
subscription-manager repos --enable codeready-builder-for-rhel-8-$(arch)-rpms
22+
# dnf config-manager --set-enabled codeready-builder-for-rhel-8-$(arch)-rpms
23+
fi
24+
EOT
25+
26+
FROM subscribed-image
27+
28+
ENV GOPROXY=https://proxy.golang.org|direct
29+
ENV GO111MODULE=off
30+
ENV GOPATH=/go
31+
ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
32+
ENV AUTO_GOPATH 1
33+
ENV DOCKER_BUILDTAGS exclude_graphdriver_btrfs
34+
ARG DISTRO
35+
ARG SUITE
36+
ENV DISTRO=${DISTRO}
37+
ENV SUITE=${SUITE}
38+
39+
RUN dnf install -y rpm-build rpmlint
40+
COPY --link SPECS /root/rpmbuild/SPECS
41+
RUN dnf builddep -y /root/rpmbuild/SPECS/*.spec
42+
COPY --link --from=golang /usr/local/go /usr/local/go
43+
WORKDIR /root/rpmbuild
44+
ENTRYPOINT ["/bin/rpmbuild"]

rpm/rhel-9/Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# syntax=docker/dockerfile:1
2+
3+
ARG GO_IMAGE
4+
ARG DISTRO=rhel
5+
ARG SUITE=9
6+
ARG BUILD_IMAGE=registry.access.redhat.com/ubi9/ubi
7+
8+
FROM ${GO_IMAGE} AS golang
9+
10+
FROM ${BUILD_IMAGE} AS subscribed-image
11+
RUN --mount=type=secret,id=rh-user --mount=type=secret,id=rh-pass <<-EOT
12+
rm -f /etc/rhsm-host
13+
14+
if [ ! -f /run/secrets/rh-user ] || [ ! -f /run/secrets/rh-pass ]; then
15+
echo "Either RH_USER or RH_PASS is not set. Running build without subscription."
16+
else
17+
subscription-manager register \
18+
--username="$(cat /run/secrets/rh-user)" \
19+
--password="$(cat /run/secrets/rh-pass)"
20+
21+
subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms
22+
# dnf config-manager --set-enabled codeready-builder-for-rhel-9-$(arch)-rpms
23+
fi
24+
EOT
25+
26+
FROM subscribed-image
27+
28+
ENV GOPROXY=https://proxy.golang.org|direct
29+
ENV GO111MODULE=off
30+
ENV GOPATH=/go
31+
ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
32+
ENV AUTO_GOPATH 1
33+
ENV DOCKER_BUILDTAGS exclude_graphdriver_btrfs
34+
ARG DISTRO
35+
ARG SUITE
36+
ENV DISTRO=${DISTRO}
37+
ENV SUITE=${SUITE}
38+
39+
RUN dnf install -y rpm-build rpmlint
40+
COPY --link SPECS /root/rpmbuild/SPECS
41+
RUN dnf builddep -y /root/rpmbuild/SPECS/*.spec
42+
COPY --link --from=golang /usr/local/go /usr/local/go
43+
WORKDIR /root/rpmbuild
44+
ENTRYPOINT ["/bin/rpmbuild"]

0 commit comments

Comments
 (0)