Added CentOS RPM package building environment

Signed-off-by: Teddysun <i@teddysun.com>
This commit is contained in:
Teddysun 2021-04-12 23:28:06 +09:00
parent 26090ded9d
commit ae9b686fa8
No known key found for this signature in database
GPG Key ID: 09BD4C080AD6C46D
3 changed files with 136 additions and 0 deletions

View File

@ -0,0 +1,35 @@
# Dockerfile for build RPM packages.
# Copyright (C) 2021 Teddysun <i@teddysun.com>
FROM --platform=${TARGETPLATFORM} centos:7
LABEL maintainer="Teddysun <i@teddysun.com>"
RUN yum install -y yum-utils epel-release centos-release-scl-rh && \
yum-config-manager --enable epel && \
yum install -y tar wget git tree gcc gcc-c++ \
sudo net-tools make cmake zstd libzstd \
python bash coreutils diffutils patch \
rpm-build rpm-devel rpmlint rpmdevtools \
devtoolset-9-gcc devtoolset-9-binutils devtoolset-9-runtime \
scl-utils asciidoc bison elfutils-libelf-devel m4 newt-devel \
openssl-devel openssl xmlto audit-libs-devel binutils-devel elfutils-devel \
gettext java-1.8.0-openjdk-devel libcap-devel numactl-devel python-devel python3 \
slang-devel xz-devel zlib-devel ncurses-devel pciutils-devel perl-ExtUtils-Embed && \
yum clean all && rm -rf /var/cache/yum /var/lib/rpm/__db*
RUN useradd builder -u 1000 -m -G users,wheel && \
echo "builder ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers && \
echo "# macros" > /home/builder/.rpmmacros && \
echo "%_topdir /home/builder/rpmbuild" >> /home/builder/.rpmmacros && \
echo "%_sourcedir %{_topdir}" >> /home/builder/.rpmmacros && \
echo "%_builddir %{_topdir}" >> /home/builder/.rpmmacros && \
echo "%_specdir %{_topdir}" >> /home/builder/.rpmmacros && \
echo "%_rpmdir %{_topdir}" >> /home/builder/.rpmmacros && \
echo "%_srcrpmdir %{_topdir}" >> /home/builder/.rpmmacros && \
mkdir -p /home/builder/rpmbuild && \
chown -R builder /home/builder
USER builder
VOLUME /home/builder
WORKDIR /home/builder/rpmbuild
CMD ["/bin/bash"]

View File

@ -0,0 +1,36 @@
# Dockerfile for build RPM packages.
# Copyright (C) 2021 Teddysun <i@teddysun.com>
FROM --platform=${TARGETPLATFORM} centos:8
LABEL maintainer="Teddysun <i@teddysun.com>"
RUN yum install -y yum-utils epel-release && \
yum-config-manager --enable epel && \
rpm -e --nodeps coreutils-single && \
yum install -y tar wget git tree gcc gcc-c++ \
sudo net-tools make cmake zstd libzstd \
bash coreutils diffutils patch \
rpm-build rpm-devel rpmlint rpmdevtools \
asciidoc audit-libs-devel binutils-devel flex \
libcap-devel newt-devel pciutils-devel perl-generators \
python3 python3-devel python3-docutils rsync xmlto bc bison \
java-devel ncurses-devel numactl-devel openssl-devel perl-devel \
elfutils-devel xz-devel perl-ExtUtils-Embed && \
yum clean all && rm -rf /var/cache/dnf /var/lib/rpm/__db*
RUN useradd builder -u 1000 -m -G users,wheel && \
echo "builder ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers && \
echo "# macros" > /home/builder/.rpmmacros && \
echo "%_topdir /home/builder/rpmbuild" >> /home/builder/.rpmmacros && \
echo "%_sourcedir %{_topdir}" >> /home/builder/.rpmmacros && \
echo "%_builddir %{_topdir}" >> /home/builder/.rpmmacros && \
echo "%_specdir %{_topdir}" >> /home/builder/.rpmmacros && \
echo "%_rpmdir %{_topdir}" >> /home/builder/.rpmmacros && \
echo "%_srcrpmdir %{_topdir}" >> /home/builder/.rpmmacros && \
mkdir -p /home/builder/rpmbuild && \
chown -R builder /home/builder
USER builder
VOLUME /home/builder
WORKDIR /home/builder/rpmbuild
CMD ["/bin/bash"]

65
docker/rpmbuild/README.md Normal file
View File

@ -0,0 +1,65 @@
## CentOS RPM package building environment by Teddysun
This docker image can be used to build RPM packages.
For more information on docker and containerization technologies, refer to [official document][1].
## Supported tags and respective `Dockerfile` links
- `latest`, `8` [*(Dockerfile)*][2]
- `7` [*(Dockerfile)*][3]
### Reference
- Supported architectures ([*more info*][4]): `amd64`, `arm64v8`
## Integration
RPMs will be built in `/home/builder/rpmbuild` folder, which should contain source archives, patches and built RPM/SRPM files.
## Prepare the host
If you need to install docker by yourself, follow the [official installation guide][5].
## User Account and Root Access
The `builder` user (UID 1000) is a member of users and wheel, and has password-less sudo as any user, any group.
## Pull the image
For CentOS 7
```bash
$ docker pull teddysun/rpmbuild:7
```
For CentOS 8
```bash
$ docker pull teddysun/rpmbuild:8
```
It can be found at [Docker Hub][6].
## Start a container
There is an example to start a container for CentOS 7 like below:
```bash
$ mkdir -m 777 -p /opt/builder7
$ docker run -it --rm --name rpmbuild7 -v /opt/builder7:/home/builder/rpmbuild teddysun/rpmbuild:7
```
There is an example to start a container for CentOS 8 like below:
```bash
$ mkdir -m 777 -p /opt/builder8
$ docker run -it --rm --name rpmbuild8 -v /opt/builder8:/home/builder/rpmbuild teddysun/rpmbuild:8
```
[1]: https://docs.docker.com/
[2]: https://github.com/teddysun/across/blob/master/docker/rpmbuild/Dockerfile.centos8
[3]: https://github.com/teddysun/across/blob/master/docker/rpmbuild/Dockerfile.centos7
[4]: https://github.com/docker-library/official-images#architectures-other-than-amd64
[5]: https://docs.docker.com/install/
[6]: https://hub.docker.com/r/teddysun/rpmbuild/