Skip to content

Commit 68349e2

Browse files
committed
Add Alma 9 rpmbuild + bazel environment for examples
This provides a consistent starting point for running rpmbuild examples using a docker container build on Alma 9. Closes: #968
1 parent 5a77a59 commit 68349e2

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
rpmbuild_docker
2+
===============
3+
4+
This provides an easy way to create an almalinux-based container that can be used
5+
to run `rpmbuild` via `pkg_rpm()` rules.
6+
7+
For example:
8+
9+
```console
10+
[rules_pkg]$ cd examples/rpm/system_rpmbuild_bzlmod/
11+
[system_rpmbuild_bzlmod]$ ../../../contrib/alma9_rpmbuild_docker/run.sh
12+
[+] Building 0.1s (9/9) FINISHED
13+
```
14+
15+
```console
16+
[devuser@fd4cc85e6e5a system_rpmbuild_bzlmod]$ bazel build test-rpm
17+
Starting local Bazel server (8.3.1) and connecting to it...
18+
INFO: Analyzed target //:test-rpm (80 packages loaded, 3318 targets configured).
19+
INFO: Found 1 target...
20+
Target //:test-rpm up-to-date:
21+
bazel-bin/test-rpm.rpm
22+
bazel-bin/test-rpm-all.rpm
23+
bazel-bin/test-rpm-1-0.all.rpm
24+
INFO: Elapsed time: 5.007s, Critical Path: 0.06s
25+
INFO: 1 process: 9 action cache hit, 1 internal.
26+
INFO: Build completed successfully, 1 total action
27+
```
28+
29+
```console
30+
[devuser@fd4cc85e6e5a system_rpmbuild_bzlmod]$ rpm -qlp bazel-bin/test-rpm.rpm
31+
/BUILD
32+
/MODULE.bazel
33+
/README.md
34+
/test_rpm.spec
35+
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM almalinux:9.6
2+
3+
ARG USER_ID
4+
ARG GROUP_ID
5+
6+
ENV BAZELISK_VERSION=v1.26.0
7+
ENV BAZELISK_URL=https://github.com/bazelbuild/bazelisk/releases/download/${BAZELISK_VERSION}/bazelisk-linux-amd64
8+
9+
RUN dnf install -y \
10+
ca-certificates \
11+
gcc-c++ \
12+
rpm-build \
13+
&& dnf clean all \
14+
&& curl -sSL -o /usr/local/bin/bazel ${BAZELISK_URL} \
15+
&& chmod +x /usr/local/bin/bazel
16+
17+
RUN groupadd --gid $GROUP_ID devgroup && \
18+
useradd --uid $USER_ID --gid $GROUP_ID --create-home --shell /bin/bash -l devuser
19+
20+
VOLUME /home/devuser/.cache
21+
22+
RUN mkdir -p /home/devuser/.cache && \
23+
chown -R ${USER_ID}:${GROUP_ID} /home/devuser/.cache
24+
25+
USER devuser
26+
WORKDIR /home/devuser
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
# Copyright 2025 The Bazel Authors. All rights reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -ueo pipefail
17+
18+
tag="${TAG:-alma9-bazel}"
19+
volume="${VOLUME:-bazel-cache}"
20+
21+
dir=$(realpath "$(dirname "$0")")
22+
repo_root="$dir/../.."
23+
24+
docker build -t "$tag" --build-arg USER_ID="$(id -u)" --build-arg GROUP_ID="$(id -g)" "$dir/docker"
25+
26+
docker_args=(
27+
-v "$volume":/home/devuser/.cache
28+
-v "$repo_root:$repo_root"
29+
-w "$PWD"
30+
--rm
31+
-i
32+
-t
33+
)
34+
exec docker run "${docker_args[@]}" "$tag" "$@"

0 commit comments

Comments
 (0)