bbc / audiowaveform

C++ program to generate waveform data and render waveform images from audio files
https://waveform.prototyping.bbc.co.uk
GNU General Public License v3.0
1.94k stars 242 forks source link

Instructions to build Centos7 RPM package and CentOS-based docker image from source #141

Closed jperville closed 3 years ago

jperville commented 3 years ago

In this issue I document how I managed to build RPM packages of audiowaveform 1.5.1 for Centos7 from the current sources.

My starting point was the source build instructions:

The result is the following Dockerfile :

#
# Start builder image => the image builds a RPM for audiowaveform and installs it under `/target/*.rpm`
#

FROM centos:7 AS audiowaveform-builder

# Use the epel repository (to provide the libmad package)
RUN INSTALL_PKGS="epel-release" && \
    yum install -y --setopt=tsflags=nodocs  $INSTALL_PKGS && rpm -V $INSTALL_PKGS && \
    yum clean all -y

# Install audiowaveform build dependencies
RUN INSTALL_PKGS="redhat-lsb-core rpm-build git make cmake gcc-c++ libmad-devel libid3tag-devel libsndfile-devel gd-devel boost-devel libmad-devel wget" && \
    yum install -y --setopt=tsflags=nodocs  $INSTALL_PKGS && rpm -V $INSTALL_PKGS && \
    yum clean all -y

# Retrieve and build source (see https://github.com/bbc/audiowaveform#building-from-source)
RUN AUDIOWAVEFORM_VERSION="1.5.1" && \
    cd /usr/local/src && \
    git clone https://github.com/bbc/audiowaveform.git && \
    cd audiowaveform && \
    git checkout "${AUDIOWAVEFORM_VERSION}" && \
    wget -qO- https://github.com/google/googletest/archive/release-1.11.0.tar.gz | tar xfz - -C . && \
    mv -f googletest-* googletest && \
    mkdir build && \
    cd build && \
    cmake -D ENABLE_TESTS=0 .. && \
    make package && \
    mkdir /target && \
    cp -v *.rpm /target && \
    cd /target && \
    rm -rf /usr/local/src/audiowaveform && \
    rpm -Uvh /target/*.rpm && \
    audiowaveform --version

#
# Start runner image => install the previously built RPM with minimal runtime dependencies
#

FROM centos:7

# Use the epel repository (to provide the libmad package)
RUN INSTALL_PKGS="epel-release" && \
    yum install -y --setopt=tsflags=nodocs  $INSTALL_PKGS && rpm -V $INSTALL_PKGS && \
    yum clean all -y

# Install audiowaveform from the RPM in the above audiowaveform-builder image
COPY --from=audiowaveform-builder /target/audiowave*.rpm /tmp/rpms/audiowave.rpm
RUN INSTALL_PKGS="libmad libsndfile libid3tag gd boost" && \
    yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && rpm -V $INSTALL_PKGS && \
    rpm -ivh --excludedocs /tmp/rpms/*.rpm && \
    rm -rf /tmp/rpms && \
    yum clean all -y

ENTRYPOINT ["/usr/bin/audiowaveform"]

Build the image like this:

docker build -t audiowaveform:local .

Test it like this:

docker run --rm audiowaveform:local --version
jperville commented 3 years ago

I am preparing 2 PRs:

chrisn commented 3 years ago

I've used this to create RPMs for Centos 7 and 8 - see the Releases page. I'll close #143 as people should now be able to download and use the RPMs directly rather than need to build their own. Thank you for contributing, it's really very helpful!

jperville commented 3 years ago

Thank you very much @chrisn , maybe I can simplify my own docker images then. Julien