Public | Automated Build

Last pushed: 3 months ago
Short Description
Provide a script to build RPM packages.
Full Description

What is openio/rpmbuild?

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.

How to use this image

Build a package

To build a package, you must specify at least a RPM specfile through the SPECFILE environment variable.

# docker run -e SPECFILE= --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= --privileged=true --rm openio/rpmbuild


specfile from GIT

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= --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= --privileged=true --rm openio/rpmbuild

or commit:

docker run -e DISTRIBUTION=fedora-22-x86_64 -e SPECFILE= --privileged=true --rm openio/rpmbuild

Alternative sources

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= SOURCES="" --privileged=true --rm openio/rpmbuild

Use cache

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.

  • Using a cache container:
# docker run -ti -v /var/cache/mock --name rpmbuild-cache-container alpine true
# docker run -e SPECFILE= --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

Access the result

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= --privileged=true -v "$(pwd)"/local/lib/mock:/var/lib/mock --rm openio/rpmbuild

Upload resulting packages

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= --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="" \
             -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 \


The included script is provided under Apache License v2.

Docker Pull Command
Source Repository