Docker RPM build env

Provides a Centos 7 build environment for compiling RPMs. Based heavily on
scripts pulled from ryanbauman's rpm-buildenv.


Like rpm-buildenv, this image assumes that you will provide a SPEC file,
most likely in the same directory as the source you wish to compile.


docker run --workdir /tmp --volume $PWD:/tmp sydneyuni/rpm-build-env your-project.spec [optional-output-directory]

Note that the workdir is the same as the provided volume, which should be the
directory containing your source and SPEC file (in this case we would run it in
the project root). The spec file argument is relative to the source
root, as is the optional output directory. If the output directory does not exist it will be created (it defaults to rpms/).

Working with the container

The container and build script make a few assumptions about your project. First,
your SPEC file must contain a valid Source line, such as this:

Source:     %{name}-%{version}.tar.gz

The build routine will automatically zip the source directory up according to
the name provided in Source it fundamentally doesn't matter what the name is;
it's mainly to satisfy the RPM toolchain's expectations of how source will be
provided. Because of this assumption, you should also use the %autosetup macro in the %prep stage, which will extract the source zip to the BUILD directory:


This Docker image expects to find your SPEC file in the source directory. An
example structure of a project might be:

  • base/
    • your-project.spec
    • Makefile
    • src/
      • source.c
      • other_source.c
    • build/
      • out.o

An example of the SPEC file for this project might be:

Name:       my-project
Version:    1.0.0
Release:    1%{?dist}
Summary:    Example RPM project
License:    MIT
Source:     %{name}-%{version}.tar.gz






You could then compile this project like this:

docker run --workdir /tmp --volume $PWD:/tmp sydneyuni/rpm-build-env your-project.spec build/