From ae9b686fa89d0f8ec96aed753013b7b73e5a664d Mon Sep 17 00:00:00 2001 From: Teddysun Date: Mon, 12 Apr 2021 23:28:06 +0900 Subject: [PATCH] Added CentOS RPM package building environment Signed-off-by: Teddysun --- docker/rpmbuild/Dockerfile.centos7 | 35 ++++++++++++++++ docker/rpmbuild/Dockerfile.centos8 | 36 +++++++++++++++++ docker/rpmbuild/README.md | 65 ++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 docker/rpmbuild/Dockerfile.centos7 create mode 100644 docker/rpmbuild/Dockerfile.centos8 create mode 100644 docker/rpmbuild/README.md diff --git a/docker/rpmbuild/Dockerfile.centos7 b/docker/rpmbuild/Dockerfile.centos7 new file mode 100644 index 0000000..1588724 --- /dev/null +++ b/docker/rpmbuild/Dockerfile.centos7 @@ -0,0 +1,35 @@ +# Dockerfile for build RPM packages. +# Copyright (C) 2021 Teddysun + +FROM --platform=${TARGETPLATFORM} centos:7 +LABEL maintainer="Teddysun " + +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"] diff --git a/docker/rpmbuild/Dockerfile.centos8 b/docker/rpmbuild/Dockerfile.centos8 new file mode 100644 index 0000000..e07571a --- /dev/null +++ b/docker/rpmbuild/Dockerfile.centos8 @@ -0,0 +1,36 @@ +# Dockerfile for build RPM packages. +# Copyright (C) 2021 Teddysun + +FROM --platform=${TARGETPLATFORM} centos:8 +LABEL maintainer="Teddysun " + +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"] diff --git a/docker/rpmbuild/README.md b/docker/rpmbuild/README.md new file mode 100644 index 0000000..d39660c --- /dev/null +++ b/docker/rpmbuild/README.md @@ -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/ \ No newline at end of file