Provide a script to build RPM packages.
1.0K
This image provides an easy way to build RPM packages without configuring a dedicated server.
It is built from a Fedora 22 distribution, and provide a Python script that wraps the process to create a package, relying on rpmbuild and Mock to build clean packages in chrooted environment.
The container should run in privileged mode.
To build a package, you must specify at least a RPM specfile through the SPECFILE environment variable.
# docker run -e SPECFILE=https://raw.githubusercontent.com/open-io/rpm-specfiles/master/json-c/json-c.spec --privileged=true --rm openio/rpmbuild
Default distribution is epel-7-x86_64, get the full list in the Mock source. Specify the DISTRIBUTION environment variable choose another:
# docker run -e DISTRIBUTION=fedora-22-x86_64 -e SPECFILE=https://raw.githubusercontent.com/open-io/rpm-specfiles/master/json-c/json-c.spec --privileged=true --rm openio/rpmbuild
If your specfile and your sources are versionned like in Fedora's repository, you can set the SPECFILE parameter to a GIT repository. By default, it points to the master branch:
docker run -e DISTRIBUTION=fedora-22-x86_64 -e SPECFILE=http://pkgs.fedoraproject.org/git/bash.git --privileged=true --rm openio/rpmbuild
You may add URL options to point a specific branch:
docker run -e DISTRIBUTION=fedora-22-x86_64 -e SPECFILE=http://pkgs.fedoraproject.org/git/bash.git?branch=f22 --privileged=true --rm openio/rpmbuild
or commit:
docker run -e DISTRIBUTION=fedora-22-x86_64 -e SPECFILE=http://pkgs.fedoraproject.org/git/bash.git?commit=469c21de51421a30eb99aad8a02148043fcdccce --privileged=true --rm openio/rpmbuild
Like for the specfile, you can specify alternative download for your source files. It can be either simple HTTP download or a GIT repository.
docker run -e DISTRIBUTION=fedora-22-x86_64 -e SPECFILE=http://pkgs.fedoraproject.org/git/bash.git?commit=469c21de51421a30eb99aad8a02148043fcdccce SOURCES="ftp://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz" --privileged=true --rm openio/rpmbuild
This image relies on Mock that uses caches to build package faster. As you create a new container from scratch each time you want to build a package, you'd feed the cache every time you run the container.
This image allows you to bind a local directory or another container to keep the cache fetched by Mock in /var/cache/mock through your packages build.
# docker run -ti -v /var/cache/mock --name rpmbuild-cache-container alpine true
# docker run -e SPECFILE=https://raw.githubusercontent.com/open-io/rpm-specfiles/master/json-c/json-c.spec --privileged=true --rm --volumes-from rpmbuild-cache-container openio/rpmbuild
To access the cache:
# docker run -ti --rm --volumes-from rpmbuild-cache-container alpine sh
You might want to get your packages, the logs or the chroot at the end of the build, you can mount /var/lib/mock on your host to access this informations:
Create a local directory:
# mkdir -pv local/lib/mock
# docker run -e SPECFILE=https://raw.githubusercontent.com/open-io/rpm-specfiles/master/json-c/json-c.spec --privileged=true -v "$(pwd)"/local/lib/mock:/var/lib/mock --rm openio/rpmbuild
You can upload the resulting packages using SCP:
# docker run -e UPLOAD_RESULT="scp://host/remote_path/?port=22&username=user&password=passwd" -e SPECFILE=https://raw.githubusercontent.com/open-io/rpm-specfiles/master/python-oiopy/python-oiopy.spec --privileged=true -v "$(pwd)"/local/lib/mock:/var/lib/mock --rm openio/rpmbuild
Or you can upload using http to an oiorepo flask web application:
OIO_REPO_HOST=`ip -4 address show dev docker0 | awk '/inet / {print substr($2,0,index($2,"/") - 1)}'`
# docker run -e UPLOAD_RESULT="http://${OIO_REPO_HOST}:5000/package" \
-e OIO_REPO_HOST="mirror2.openio.io" \
-e OIO_PROD="sds" \
-e OIO_PROD_VER="16.10" \
-e OIO_DISTRO="centos" \
-e OIO_DISTRO_VER="7" \
-e OIO_ARCH="x86_64" \
-e OIO_COMPANY="openio" \
-e OIO_PACKAGE="python-oiopy" \
--privileged=true \
-v "$(pwd)"/local/lib/mock:/var/lib/mock \
--rm \
openio/rpmbuild
The included script is provided under Apache License v2.
Content type
Image
Digest
sha256:ff55eb80a…
Size
387.4 MB
Last updated
almost 6 years ago
docker pull openio/rpmbuild