@@ -42,6 +42,7 @@ EXTRA_DIST += \
utilities/containers/Makefile \
utilities/containers/openbfdd.patch \
utilities/containers/py-requirements.txt \
+ utilities/containers/prepare.sh \
utilities/containers/fedora/Dockerfile \
utilities/containers/ubuntu/Dockerfile \
utilities/docker/Makefile \
@@ -45,41 +45,14 @@ RUN dnf -y update \
&& \
dnf clean all
-# Compile sparse from source
-WORKDIR /workspace/sparse
-
-RUN git clone git://git.kernel.org/pub/scm/devel/sparse/sparse.git \
- /workspace/sparse \
- && \
- make -j4 PREFIX=/usr HAVE_LLVM= HAVE_SQLITE= install
-
-# Compile OpenBFDD from source
-WORKDIR /workspace/OpenBFDD
+WORKDIR /workspace
COPY $CONTAINERS_PATH/openbfdd.patch /tmp/openbfdd.patch
-RUN git clone https://github.com/dyninc/OpenBFDD.git \
- /workspace/OpenBFDD \
- && \
- git apply /tmp/openbfdd.patch \
- && \
- ./autogen.sh \
- && \
- ./configure --enable-silent-rules \
- && \
- make \
- && \
- make install
-
-WORKDIR /workspace
-
COPY $CONTAINERS_PATH/py-requirements.txt /tmp/py-requirements.txt
-# Update and install pip dependencies
-RUN python3 -m pip install --upgrade pip \
- && \
- python3 -m pip install wheel \
- && \
- python3 -m pip install -r /tmp/py-requirements.txt
+COPY $CONTAINERS_PATH/prepare.sh /tmp/prepare.sh
+
+RUN /tmp/prepare.sh
CMD ["/usr/sbin/init"]
new file mode 100755
@@ -0,0 +1,36 @@
+#!/bin/bash -xe
+
+function compile_sparse()
+{
+ git clone git://git.kernel.org/pub/scm/devel/sparse/sparse.git \
+ /workspace/sparse
+
+ pushd sparse
+ make -j4 PREFIX=/usr HAVE_LLVM= HAVE_SQLITE= install
+ popd
+}
+
+function compile_openbfdd()
+{
+ git clone https://github.com/dyninc/OpenBFDD.git \
+ /workspace/OpenBFDD
+
+ pushd OpenBFDD
+ git apply /tmp/openbfdd.patch
+ ./autogen.sh
+ ./configure --enable-silent-rules
+ make
+ make install
+ popd
+}
+
+function install_python_dep()
+{
+ python3 -m pip install --upgrade pip
+ python3 -m pip install wheel
+ python3 -m pip install -r /tmp/py-requirements.txt
+}
+
+compile_sparse
+compile_openbfdd
+install_python_dep
@@ -45,48 +45,21 @@ RUN apt update -y \
&& \
apt clean
-# Compile sparse from source
-WORKDIR /workspace/sparse
-
-RUN git clone git://git.kernel.org/pub/scm/devel/sparse/sparse.git \
- /workspace/sparse \
- && \
- make -j4 PREFIX=/usr HAVE_LLVM= HAVE_SQLITE= install
-
-# Compile OpenBFDD from source
-WORKDIR /workspace/OpenBFDD
+WORKDIR /workspace
COPY $CONTAINERS_PATH/openbfdd.patch /tmp/openbfdd.patch
-RUN git clone https://github.com/dyninc/OpenBFDD.git \
- /workspace/OpenBFDD \
- && \
- git apply /tmp/openbfdd.patch \
- && \
- ./autogen.sh \
- && \
- ./configure --enable-silent-rules \
- && \
- make \
- && \
- make install
-
-WORKDIR /workspace
-
COPY $CONTAINERS_PATH/py-requirements.txt /tmp/py-requirements.txt
+COPY $CONTAINERS_PATH/prepare.sh /tmp/prepare.sh
+
# Ubuntu 24.04 marks the Python installation as externally managed, allow pip
# to install the packages despite that.
ENV PIP_BREAK_SYSTEM_PACKAGES 1
-# Update and install pip dependencies
-RUN python3 -m pip install --upgrade pip \
- && \
- python3 -m pip install wheel \
- && \
- python3 -m pip install -r /tmp/py-requirements.txt
-
# The Python Babel fails to detect timezone when it is set to UTC only.
ENV TZ Etc/UTC
+RUN /tmp/prepare.sh
+
CMD ["/sbin/init"]
Move common preparation steps into script that can be invoked by both container builds. This will ensure that any update will be reflected in both containers, and it reduces the duplication between both containers. Signed-off-by: Ales Musil <amusil@redhat.com> --- utilities/automake.mk | 1 + utilities/containers/fedora/Dockerfile | 35 +++--------------------- utilities/containers/prepare.sh | 36 +++++++++++++++++++++++++ utilities/containers/ubuntu/Dockerfile | 37 ++++---------------------- 4 files changed, 46 insertions(+), 63 deletions(-) create mode 100755 utilities/containers/prepare.sh